Does AWS CDK create default stack name in CloudFormation?

人盡茶涼 提交于 2019-12-11 05:57:23

问题


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


回答1:


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' });


来源:https://stackoverflow.com/questions/57122045/does-aws-cdk-create-default-stack-name-in-cloudformation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!