问题
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