Skip to content

(aws-ecs): Expose environment on containerDefinition #17867

@biffgaut

Description

@biffgaut

Description

There doesn't seem to be a way to update the environment variables on an already instantiated container in a TaskDefinition. Exposing environment on ContainerDefinition would allow clients to add more environment variables to an already instantiated TaskDefinition/Container

Use Case

My use case is create the taskdef/container, then programmatically choose to give that container access to a dynamically chosen set of queues, buckets, topics, etc. As these are dynamically named, I use environment variables to identify the resources to the code within my container. 'addPropertyOverride' allows me to set the variables once, but it deletes the current contents rather than allowing me to add more.

Proposed Solution

From looking at the code in container-definition.ts, it seems that this would require:

  • Creating a public property on ContainerDefinition
  • Assigning the environment from the props to the public property in the constructor
  • Changing the rendering to use the property rather than the private props property
  • Updating tests

It seems too simple to have not been done before - is there a reason things are the way they are that I don't see?

Other information

No response

Acknowledge

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-ecsRelated to Amazon Elastic Containerfeature-requestA feature should be added or improved.needs-triageThis issue or PR still needs to be triaged.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions