Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ianblenke/84e9b1234803ed58aaa8 to your computer and use it in GitHub Desktop.
Save ianblenke/84e9b1234803ed58aaa8 to your computer and use it in GitHub Desktop.
Discovering the currently deployed version on an elasticbeanstalk EC2 instance
AWS_DEFAULT_REGION=$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r .region)
EC2_INSTANCE_ID=$(curl -sL http://169.254.169.254/latest/meta-data/instance-id)
EB_ENVIRONMENT_ID=$(aws ec2 describe-tags --filter Name=resource-id,Values=$EC2_INSTANCE_ID --region $AWS_DEFAULT_REGION | jq -r '.Tags | .[] | select(.Key=="elasticbeanstalk:environment-id") | .Value')
EB_APPLICATION_VERSION=$(aws elasticbeanstalk describe-environments --environment-ids $EB_ENVIRONMENT_ID --region $AWS_DEFAULT_REGION --region $AWS_DEFAULT_REGION | jq -r '.Environments | .[] | .VersionLabel')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment