Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

How to update container environment variables #34

Closed
MarkPolivchuk opened this issue Feb 2, 2018 · 2 comments
Closed

How to update container environment variables #34

MarkPolivchuk opened this issue Feb 2, 2018 · 2 comments

Comments

@MarkPolivchuk
Copy link

I'm switching my application's deployment to CodePipeline and the ECS. Is there a way using this API to update the container's environment variables? Previously I was using the CLI to register the task definition as follows:

export ENVIRONMENT=$(<environment.json)
aws ecs register-task-definition --family <family_name> --task-role-arn <iam_role> --container-definitions "$ENVIRONMENT"
aws ecs update-service --cluster <cluster_name> --service <service_name> --task-definition <family_name> --region us-west-2

And whatever variables were set in environment.json would be loaded into the container. I can't find any documentation describing how to set this using CloudFormation. Any ideas?

@jpignata
Copy link
Contributor

jpignata commented Feb 3, 2018

Hi! The native CodePipeline -> ECS integration will only update the container definitions' image attribute so you cannot use it to manage environment variables. Luckily, you have a couple of other options:

  • You can use a Lambda function instead to drive your deployment and do something similar to the above to edit both the image and environment attributes.
  • If you're using CloudFormation to manage your task definition and service, you can use these templates to manage those fields instead of the native integration. See the documentation for more details and a previous iteration of this refarch for an example.

Hope that helps!

@jpignata jpignata closed this as completed Feb 3, 2018
@MarkPolivchuk
Copy link
Author

Thank you for the quick response!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants