Amir Mehler
Amir Mehler

Reputation: 4682

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?

Upvotes: 4

Views: 2750

Answers (3)

Amit Naidu
Amit Naidu

Reputation: 2648

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.

Upvotes: 1

Amir Mehler
Amir Mehler

Reputation: 4682

Answer 1. In order to have tags in elastic beanstalk that would be applied on any ec2 instance created for that environment - they must be set during the creation of the environment. 2. For existing environments, it's very simple to save configurations, create an alternative environment, set the tags right, and swap the URLs until you get your original env configured right.

This guy explains it well: http://www.boringgeek.com/add-or-update-tags-on-existing-elastic-beanstalk-environments/

Upvotes: 0

Brooks
Brooks

Reputation: 7410

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

Upvotes: 1

Related Questions