Home > OS >  AWS CDK Configuration File With Parameters That Can Be Used In Code
AWS CDK Configuration File With Parameters That Can Be Used In Code

Time:07-29

I'm using the AWS CDK, and currently I have parameters that I want to be able to change in a sort of configuration file. I can't use the --parameters argument from the command line because A) I need to use the parameter values in the actual code (mainly in function calls/if statements) and B) There are enough parameters that it would be annoying to type every single one into the command line.

Is there some type of way I can just define a JSON or YAML file that the user can edit, and then use those values directly in the cdk_stack.py file?

CodePudding user response:

AWS CDK Context is recommended way to do that:

https://docs.aws.amazon.com/cdk/v2/guide/context.html

CodePudding user response:

This question doesn't exactly need an answer. However, you can create a .json file and then simply add a key named "params" and the value as a list or whatever you want to name it. There, the user can enter the parameter names, then using the open() function and the json module you can read the file using python.

  • Related