overexchange
overexchange

Reputation: 1

Does AWS CDK create default stack name in CloudFormation?

Using CloudFormation template, CloudFormation service ask for a stack name(AWS::StackName) before applying the template.

Using AWS CDK, we run cdk synth to create cfn template & cdk deploy to deploy services based on the template.

Does AWS CDK create default stack name in Cloudformation service? after running cdk deploy

Upvotes: 2

Views: 5662

Answers (1)

bgdnlp
bgdnlp

Reputation: 1145

In order to create a stack you have to instantiate an object for that stack. When you do, you pass the stack name as a parameter. Example in Python:

class MyStackClass:
    (...)

# You have to have an app
app = core.App()
# Here's the stack
MyStack = MyStackClass(app, "StackName")

Other than that, see the docs:

The physical names of the AWS CloudFormation stacks are automatically determined by the AWS CDK based on the stack's construct path in the tree. By default, a stack's name is derived from the construct ID of the Stack object, but you can specify an explicit name using the stackName prop, as follows.

new MyStack(this, 'not:a:stack:name', { stackName: 'this-is-stack-name' });

Upvotes: 5

Related Questions