Michael Leiss
Michael Leiss

Reputation: 5670

Find Beanstalk VPC-ID via AWS CLI

I am struggling hard to find the VPC-ID for an Elastic Beanstalk created via eb create:

aws elasticbeanstalk describe-environments --application-name myapplication

I can fetch the Environment ID but found no command to fetch the VPC-ID for that environment.

I would need a solution that is either able to:

A. Tag the VPC on Beanstalk creation so i can find it by

aws ec2 describe-vpcs --filters Name=tag:Name,Values=myVPCTAG

B. Find VPC-ID for the Beanstalk Environment ID

C. However goal is to get the VPC ID for a Beanstalk Environment, no matter how.

Upvotes: 2

Views: 251

Answers (1)

Marcin
Marcin

Reputation: 238199

You can try the following command which will print out the VPCId on condition that you've set your EB to be in a VPC:

aws elasticbeanstalk describe-configuration-settings \
    --application-name myapplication\
    --environment-name <env-name> \
    --query "ConfigurationSettings[].OptionSettings[?OptionName=='VPCId'].Value" \
    --output text

If you created the EB environment without specifying VPC, the output will be empty, and it should be safe to assume that your EB is in a default VPC.

Upvotes: 2

Related Questions