Ali
Ali

Reputation: 127

Getting information about deployment from within an instance of AWS Elastic Beanstalk

My specific need is to get the list of EC2 instances in the deployment from within one of the instances.

I've tried using AWS command line for example aws elb describe-load-balancers however it would just give details of all my AWS services. I know you can specify an instances name with --load-balancer-name but I just don't have access to that from within the instance automatically.

Perhaps a file can be created on instance creation by placing something in .ebextensions?

Upvotes: 2

Views: 276

Answers (1)

Rico
Rico

Reputation: 61669

You can do it in a two step process using the AWS CLI.

First you get the endpoint for your Elastic Beanstalk application:

aws elasticbeanstalk describe-environments --query='Environments[?ApplicationName==`Your-application-name`].EndpointURL'

Then you use the endpoint to get the instances:

aws elb describe-load-balancers --query='LoadBalancerDescriptions[?DNSName==`load-balancer-end-point-from-previous-step`].Instances[0]'

Upvotes: 2

Related Questions