Search code examples
amazon-web-servicesamazon-ec2amazon-elastic-beanstalk

How can I find out the Elastic Beanstalk environment a given EC2 instance is running on from the CLI?


I have an application deployed to Elastic Beanstalk with the Mutli-Container Docker configuration, which is backed by ECS and further backed by EC2. When I SSH onto the EC2 instance, is there some command I can run to identify the name of the EB application / environment that it's running under? Is there anything like aws elasticbeanstalk get-current-environment?


Solution

  • The EB environment name and id is present in your instance tags. You could run the AWS CLI: aws ec2 describe-tags to get the environment name. The tag keys would be:

    • elasticbeanstalk:environment-id
    • elasticbeanstalk:environment-name

    Please note: you would need an IAM role attached to the instances with ec2:DescribeTags permission for this command to work.