Add or Update Tags on Existing Elastic Beanstalk Environments

Back in May, Amazon introduced the ability to tag your Beanstalk environments. This is great for anyone that properly uses tags to monitor, track and account for the resources they are using. One challenge that I’ve run into recently, though, is that this is only during the creation of an environment; AWS currently doesnt offer the ability to add, remove or update tags to existing environments.

For those of you that want to make that happen, here are some simple, albeit long, instructions on how to rotate environments out with new, properly tagged ones.

From the AWS Console, select Elastic Beanstalk from the Services Menu.

Click the name of the application you wish to tag. This will take you to the “Environments” view for this particular app.

From the “Actions” menu at the top right of the console, choose “Launch New Environment”.

Follow the wizard to spin up a new “B” environment for the specific environment you wish to update.

For example, if this were for a “NODE-APP-PRD” environment, create an environment titled “NODE-APP-PRD-B”.

Ensure the configurations matche that of the desired environment. (One thing you could do is save a configuration of the base environment.)

Ensure that the correct version of the code is deployed to this environment.

For this environment, do not worry about putting any tags in; this is simply a temporary space and you will terminate it once you’re done.

Have the development team for the App test the environment and confirm functionality.

If everything is working as expected, click on the title of the new “B” environment to view that specific environment.

From the “Actions” menu on the top right, select “Save Configuration” to save a copy of the configuration. Name the configuration after the environment it is for.

From the “Environments” view for the application, click the “Swap URLs” button from the top right.

Select the correct two environments that you would like to swap and click the “Swap” button.

Once the URL swap is complete, have the development team test the app again and confirm functionality.

From the “Environments” view for the application, click the title of the original environment.

From the “Actions” menu on the top right and select “Terminate the original environment.

This will warn that the URL “NODE-APP-PRD-B.elasticbeanstalk.com” will be deleted. This is ok; it’s a temp URL anyway. The real URL is currently assigned to the “B” environment.

Once the environment has been terminated, return to the “Environments” view for the application and click “Launch New environment” from the actions menu.

Follow the wizard to recreate the original environment.

Be sure to select the configuration you just saved.

Enter in the correct tags following the format that works for your organization.

Launch the new environment.

Once the environment is launched, confirm the configuration settings are correct and that the tags are showing up properly.

Have the development team confirm that the new environment is functioning properly.

From the “Environments” view for this application, select “Swap URLs” from the top right and swap the A and B URLS. This will point the original URL to the new, properly tagged environment.

Have the development team confirm that the environment is functioning properly

Terminate the “B” environment.

Thats pretty much it. While there are a lot of steps, its pretty straight forward for an interim option while we wait for updated AWS functionality. Another benefit of following this process is that it allows you to make the swap without any downtime for your end users.

If you have any suggestions or thougths on this, let me know in the comments!

Curtis Rissi

Solutions Architect and Full Stack Engineer by day and mad scientist by night. I specialize in making the impossible possible through code and technology. I also make some crazy good Korean BBQ. You know you want to try it.

Disclaimer: I work for AWS, but unless otherwise stated, the words and thoughts expressed in this blog are my own.