Frank Mancini
Frank Mancini

Reputation: 157

AWS CDK synth and different cdk.json files

So, I have 3 different cdk.json files with different name/value pairs: cdk.json, cdk-west.json cdk-east.json

When, I run a synth or deploy, can I specify a specific json file instead of the default cdk.json one?

I know you can change profiles with the --profile option, but not sure about cdk.json

Upvotes: 7

Views: 2755

Answers (2)

Mitchell Arthur
Mitchell Arthur

Reputation: 21

A good way around this is to add an "environment" attribute to your cdk.json file with attributes for each environment that contain settings for that environment.

{
...
"environments":{
   "xxxxxxxxxxxx":{
      "name": "dev",
      "awsAccountId":"xxxxxxxxxxxx",
      "awsRegion":"us-west-2",
      "logLevel":"debug",
      "customSetting": "value 1",
      ...
   },
   "prod-west-1-account-id":{
      "name": "prod-us-west-1",
      ...
   },
   "prod-west-2-account-id":{
      "name": "prod-us-west-2",
      ...
   }
}

Then each Stack can grab the appropriate environment configuration based on the value of "this.account"

Upvotes: 2

mon
mon

Reputation: 22244

Unfortunately, there is no such option.

Upvotes: 2

Related Questions