AWS CDK 是否在 CloudFormation 中创建默认堆栈名称?

Does AWS CDK create default stack name in CloudFormation?

使用 CloudFormation 模板,CloudFormation 服务在应用模板之前要求提供堆栈名称(AWS::StackName)。

使用 AWS CDK,我们 运行 cdk synth 创建 cfn 模板 & cdk deploy 基于模板部署服务。

AWS CDK 是否在 Cloudformation 服务中创建默认堆栈名称?在 运行宁 cdk deploy

之后

为了创建堆栈,您必须为该堆栈实例化一个对象。当您这样做时,您将堆栈名称作为参数传递。 Python 中的示例:

class MyStackClass:
    (...)

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

除此之外,参见 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' });