Aws-cdk: Support multiple context files via commandline parameter

Created on 25 Apr 2019  路  5Comments  路  Source: aws/aws-cdk

In our use case we need to specify some parameters based on deployment environment.
Like tag "environment" which valua may be prod, staging, devel, testing etc. depends on where cdk app is going to be deployed.

Adding those to cdk.json under "context" key is useful but what is missing is ability to specify cdk.json file used when deploy/synth.

So it would be nice to have parameter like "--context-file":
cdk deploy --context-file cdk.prod.json
or
cdk deploy --context-file cdk.devel.json

closing-soon feature-request needs-triage

Most helpful comment

I think that this is a pretty valid use case and I'd like to see it reopened. 馃檪

I don't think that @tomilaurell is a valid solution since it seems undocumented, unupdated and unused.

I think that being able to select the context as runtime is a basic functionality to be able to reuse code between multiple environments.

All 5 comments

-- Promoting my approach to similar problem --

I have just implemented similar feature for my purposes in the npm-package:
https://www.npmjs.com/package/cdk-infra-properties
https://github.com/tomilaurell/cdk-infra-properties

Example:
https://github.com/tomilaurell/cdk-infra-properties-simple-example

This is based on "infra.properties"-files. Branch specific files (infra-BRANCHNAME.properties) will overwrite properties set in default file. Properties in the subfolders overwrite those set at higher levels. More specific files overwrite more generic. We have used this approach succesfully for years with this project: https://github.com/NitorCreations/nitor-deploy-tools
I copied the idea from that to try how it works with AWS-CDK. Turned out to work quite well!

I will write documentation for that during the next week.

Hi @kertzi ! I apologize for the late reply. Did @tomilaurell 's solution work for you? (Thanks @tomilaurell 馃憤)
I will close this issue shortly if no response.

Hi @kertzi ! I apologize for the late reply. Did @tomilaurell 's solution work for you? (Thanks @tomilaurell 馃憤)
I will close this issue shortly if no response.

Looks good! Thanks

I think that this is a pretty valid use case and I'd like to see it reopened. 馃檪

I don't think that @tomilaurell is a valid solution since it seems undocumented, unupdated and unused.

I think that being able to select the context as runtime is a basic functionality to be able to reuse code between multiple environments.

This feature would by greatly appreciated to enable us to be able to have a separate context file for devel that we don't have to commit to VCS. IMO should be reopened.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DrLuke picture DrLuke  路  45Comments

eladb picture eladb  路  33Comments

rix0rrr picture rix0rrr  路  61Comments

AlexCheema picture AlexCheema  路  32Comments

PygmalionPolymorph picture PygmalionPolymorph  路  53Comments