Skip to content

Add env_file support to sidecars #4447

@carlosaherrera

Description

@carlosaherrera

This configuration works as expected. The variables declared in both the test and sidecars sections get passed to the containers.

# You can override any of the values defined above by environment.
environments:
  # Although not mentioned in documentation, configuring sidecar environment-specific variables is supported.
  # ref: https://github.com/aws/copilot-cli/issues/3674#issuecomment-1157084196
  test:
    variables:
      SOME_VARIABLE1: 'somevalue1'
      SOME_VARIABLE2: 'somevalue2'
    sidecars:
      mysidecar1:
        variables:
          SOME_VARIABLE1: 'somevalue1'
          SOME_VARIABLE2: 'somevalue2'

But it's rather redundant. Especially when I need to pass the same variables to all containers. I thought I could be more succinct by utilizing the env_file param like so

# You can override any of the values defined above by environment.
environments:
  # Although not mentioned in documentation, configuring sidecar environment-specific variables is supported.
  # ref: https://github.com/aws/copilot-cli/issues/3674#issuecomment-1157084196
  test:
    env_file: env/.test.env
    sidecars:
      mysidecar1:
        env_file: env/.test.env

The main service container gets passed the environment variables just fine. Good. But the sidecars don't. So it looks like I have to resort to the former approach.

Metadata

Metadata

Assignees

Labels

type/featureIssues that are new feature requests.type/requestIssues that are created by customers.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions