Andrew
Andrew

Reputation: 5715

Get active elastic beanstalk environment info via AWS CLI

How can I retrieve information using the AWS CLI about the active elastic beanstalk instance setup in a blue/green manner (where two environments are running side by side).

Running the following command gives me an array of environments for my application:

aws elasticbeanstalk describe-environments --application-name MyApp

Although I would prefer a command which only returned the active environment (and not the inactive).

Is the most accurate way to tell this by CNAME containing the string inactive from the command output?

The specific piece of data which I require is EnvironmentName.

Upvotes: 1

Views: 742

Answers (1)

BMW
BMW

Reputation: 45223

You need several aws cli to find it out.

Get the hosted zones ids

aws route53 list-hosted-zones

filter out target zone id

list elastic beanstalk applications

aws elasticbeanstalk describe-environments --application-name MyApp | jq -r '.Environments[].CNAME'

export its CNAME

get the record sets in that zone id.

aws route53 list-resource-record-sets --hosted-zone-id <hosted-zone-id>

filter out the CNAME which you get from above elasticbeanstalk cli

Upvotes: 2

Related Questions