Skip to content

Substitute environment variables in manifests #2912

@iamhopaul123

Description

@iamhopaul123

Background

Currently Copilot manifest does not support any form of pseudo-variables. On one hand, users cannot refer to the shell environment variables. On the other hand, they have to specify very similar values for different environments repetitively using environment override. For example, in our secret init doc, users during next step after the secret creation, they have to specify different DB_PASSWORD for test and dev environment.

Given the above-mentioned reasons, it is worth for us to introduce appropriate pseudo-variables to our manifest to make it more flexible.

Related Issues

Proposal

Shell environment variables

name: my-service
type: Load Balanced Web Service
image:
  location: id.dkr.ecr.zone.amazonaws.com/project-name:${TAG}
  port: 3333

Pre-defined variables

secrets:
   DB_PASSWORD: /copilot/my-app/${COPILOT_ENVIRONMENT_NAME}/secrets/db_password
environments:
    prod:
      secrets: 
          <specific environment variable for prod>
    dev:
      secrets:
          <specific environment variable for dev>

Available pre-defined variables:

  • COPILOT_APPLICATION_NAME
  • COPILOT_ENVIRONMENT_NAME

It’s worth noting that we won’t allow users to override any of our predefined variables. Once we detect they have shell variables with the same name, we’ll log warning messages saying we won’t override these variables for them. Otherwise, it is possible they have ${COPILOT_ENVIRONMENT_NAME} defined in the shell session where they run Copilot without realizing its existence.

Also Copilot should error out if users are trying to refer to an undefined env var in their manifest.

Metadata

Metadata

Assignees

Labels

area/manifestIssues about infrastructure-as-code templates.type/designIssues that are design proposals.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions