Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set tags on ec2 instances created by elastic-beanstalk

Is there a way to do this from Beanstalk? or do I have to do it myself once the new instance is up via .ebextensions or something like that?

like image 553
Amir Mehler Avatar asked Nov 16 '25 19:11

Amir Mehler


2 Answers

This feature was not available at the time this question was asked. There were many requests for this ever since the tagging feature was first introduced in 2014.

Support for updating EB tags was eventually added in Oct 2017.

You can now manage tags in the Beanstalk Management Console, with the EB CLI or with the AWS CLI.

like image 119
Amit Naidu Avatar answered Nov 18 '25 17:11

Amit Naidu


If you want to set the tags from within your Elastic Beanstalk instance, you can certainly SSH in, install the AWS CLI and set the tags via the command line. Or, whatever application you're deploying on Beanstalk can do so via the SDK (e.g. Java).

Via CLI:
http://docs.aws.amazon.com/cli/latest/reference/ec2/create-tags.html

create-tags [--dry-run | --no-dry-run] --resources <value> --tags <value> [--cli-input-json <value>] [--generate-cli-skeleton]

Via SDK:
http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/ec2/model/CreateTagsRequest.html

(pseudo-code)

Authorize via credentials
Instantiate CreateTagsRequest with specific resource ID
call setTags(Collection<<**String**>> tags) on the CreateTagsRequest object

From outside the environment, you can set the tags via the console or via EB CLI. http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.tagging.html

eb create --tags mytag1=value1,mytag2=value2

Note, you can also set regular environment variables via eb create.

eb create --envvars key=value
like image 21
Brooks Avatar answered Nov 18 '25 17:11

Brooks