It might be to late to answer this, I also new in using CDK but I implement such functionality by providing additional context through cdk command option --context and then retrieve the rest of the context defined in cdk.json file based on it, as the sample shown below, cdk.json file:
I synth the cdk app by issuing command cdk synth --profile prod --context env=dev and the conf constant result would be like,
{
"someProperty": "developmentDomain.com"
}
Also I want to keep the env context provided receives dev or prod value only, hence I implement schema validation using zod while parsing the env context
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thank you for taking the time to put this together.
I have been struggling with this for weeks, and even AWS Support does not know how to do it.
I have two environments, dev and prod. I have two cli profiles configured, dev and prod.
I did not set a default config, so I force myself to always declare the profile like this $cdk deploy stackName --profile dev
What I am trying to do is set property values based on the profile being used to deploy.
if ---> $cdk deploy stackName --profile prod
then ---> someProperty : productionDomain.com
if --->$cdk deploy stackName --profile dev
then ---> someProperty : developmentDomain.com
I read (and re-read) your post but it's still over my head. Please let me know if you would be willing to dumb it down to my example above.
It might be to late to answer this, I also new in using CDK but I implement such functionality by providing additional context through cdk command option
--contextand then retrieve the rest of the context defined incdk.jsonfile based on it, as the sample shown below,cdk.jsonfile:bin/app.tsfile:I synth the cdk app by issuing command
cdk synth --profile prod --context env=devand theconfconstant result would be like,Also I want to keep the
envcontext provided receivesdevorprodvalue only, hence I implement schema validation using zod while parsing theenvcontext