copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

support `secrets_file` in the manifest

Open KollaAdithya opened this issue 1 year ago • 7 comments

conversation from gitter https://app.gitter.im/#/room/#aws_copilot-cli:gitter.im/$iWOLIz9DdgbThFO8oe4-x26Tk1IwT1rHxxoUxwAz9_c

Current Scenario

Say I have two services serviceA and serviceB

.
├── copilot                        (application directory)
│   ├── .workspace                 (workspace summary)
│   ├── serviceA
│   │   └── manifest.yml           (serviceA manifest)
│   ├── serviceB
│   │   └── manifest.yml           (serviceB manifest)

In order to specify secrets for serviceA and serviceB. In ServiceA manifest

secrets:
  GITHUB_WEBHOOK_SECRET: GH_WEBHOOK_SECRET
  DB:
    secretsmanager: 'demo/test/mysql'
  DB_PASSWORD:
    secretsmanager: 'demo/test/mysql:password::'
 
sidecars:
  nginx:
      GITHUB_WEBHOOK_SECRET: GH_WEBHOOK_SECRET
      DB:
        secretsmanager: 'demo/test/mysql'
      DB_PASSWORD:
        secretsmanager: 'demo/test/mysql:password::'
  nginx2:
      GITHUB_WEBHOOK_SECRET: GH_WEBHOOK_SECRET
      DB:
        secretsmanager: 'demo/test/mysql'
      DB_PASSWORD:
        secretsmanager: 'demo/test/mysql:password::'   

In ServiceB manifest

secrets:
  GITHUB_WEBHOOK_SECRET: GH_WEBHOOK_SECRET
  DB:
    secretsmanager: 'demo/test/mysql'
  DB_PASSWORD:
    secretsmanager: 'demo/test/mysql:password::'
 
sidecars:
  nginx:
      GITHUB_WEBHOOK_SECRET: GH_WEBHOOK_SECRET
      DB:
        secretsmanager: 'demo/test/mysql'
      DB_PASSWORD:
        secretsmanager: 'demo/test/mysql:password::'
  nginx2:
      GITHUB_WEBHOOK_SECRET: GH_WEBHOOK_SECRET
      DB:
        secretsmanager: 'demo/test/mysql'
      DB_PASSWORD:
        secretsmanager: 'demo/test/mysql:password::'   

By looking at the manifest files, This feels redundant to specify same secrets across multiple services.

ASK

Instead we can have specify secrets_file in the manifests across services where secrets_file is path to a file from the root of your workspace. (This is similar to env_file in the manifest)

.
├── copilot                        (application directory)
│   ├── .workspace                 (workspace summary)
│   ├── serviceA
│   │   └── manifest.yml           (serviceA manifest)
│   ├── serviceB
│   │   └── manifest.yml           (serviceB manifest)
│   ├── secretsdir
│   │   └── secrets.yml

Where secrets.yml contains all the secrets.

GITHUB_WEBHOOK_SECRET: GH_WEBHOOK_SECRET
DB:
  secretsmanager: 'demo/test/mysql'
DB_PASSWORD:
  secretsmanager: 'demo/test/mysql:password::'   

Copilot should be able to parse this secrets.yml file.

In manifest for serviceA will have

secrets_file: ./secretsdir/secrets.yml

In manifest for serviceB wil have

secrets_file: ./secretsdir/secrets.yml

KollaAdithya avatar Aug 18 '23 19:08 KollaAdithya

A Workaround shared by @interu using yaml Node Anchor and Aliases incase of specifying secrets in a single service. https://github.com/aws/copilot-cli/issues/5203#issuecomment-1683637218

KollaAdithya avatar Aug 18 '23 19:08 KollaAdithya

Related: #3778.

huanjani avatar Aug 21 '23 19:08 huanjani

+1 for this feature request, currently it's a lot of copy/pasta-spaghetti code to update every time we add a new env var that's shared across our many separate service manifests

and unfortunately, the above work-around doesn't help due to the very fact that we have many separate service manifests :(

vskov147 avatar Aug 24 '23 00:08 vskov147

or a least to let manifest include other files (similarly to the include in docker compose)

sebastianovide avatar Jan 08 '24 21:01 sebastianovide

👍🏼 to this as well, we are having to store the whole .env in secrets manager and do some smelly script work to expose each in the dockerfile

ssyberg avatar Jan 30 '24 14:01 ssyberg

Related request: https://github.com/aws/copilot-cli/issues/2699

jlucas91 avatar Aug 06 '24 16:08 jlucas91

+1 to this issue. Would make implementing new secrets across multiple services much less tedious.

ryanc-scalegrowth avatar Aug 09 '24 00:08 ryanc-scalegrowth