Cris Merritt
Cris Merritt

Reputation: 51

Is there a programmatic way in CDK to set Cfn parameter values?

In CDK, I know that I can set Cfn parameters on the cdk command line with the --parameters option (as documented here).

My question is: can I do the same programmatically in my CDK app?

For example, I know that I can set context values on the cdk command line with the --context option, and I can do the same programmatically with the construct.node.setContext() method. I'm looking for such a facility to set Cfn parameters. I thought it might be in cdk.Stack, but I'm not finding anything. Thanks!

Upvotes: 5

Views: 1735

Answers (1)

Danil Valov
Danil Valov

Reputation: 663

I'll try to answer.

As I understand you tell about the following construction:

    const yourValue = new CfnParameter(this, 'yourValueId', {
      type: 'String',
      description: 'Your value description',
      default: 'DefaultValue',
    });

    this.vpc = new Vpc(this, 'VpcForExample', {
      cidr: yourValue.valueAsString,
      // ...
    });

More information about it:

Upvotes: 1

Related Questions