简体   繁体   中英

CloudFormation nested stack name

I need to set nested stack name explicitly in a CloudFormation template, but don't see such option in AWS documentation . Is there way to achieve this? I can specify stack name, when running a parent stack, but all nested stacks, got a randomly generated stack name, based on a resource name created, like:

VPC: Type: AWS::CloudFormation::Stack Properties: TemplateURL: https://s3-eu-west-1.amazonaws.com/cf-templates-wtmg/vpc.yaml Parameters: EnvironmentName: :Ref AWS::StackName

Which will generate nested stack name in form parent_stack_name-VPC-random_hash .

Yes. I was looking for the same thing also but currently it's not available.

I think the reason of you wanted a specific stack name is to use it for output referral?

What you can do/I did was:

1) For those in the same parent stack, you need to output from nested stack and then refer directly from the stack like !GetAtt NestedStack1.outputs.Output1

2) For those which are outside for parent stack, you will need to output twice. Once in the nested stack and once in the parent stack. Then you can refer to the parent stack output.

Hope this will help.

I ran into the same thing just today.

From the official AWS documentation, supporting the original answer to this question: You can add output values from a nested stack within the containing template. You use the GetAtt function with the nested stack's logical name and the name of the output value in the nested stack in the format Outputs.NestedStackOutputName. You can add output values from a nested stack within the containing template. You use the GetAtt function with the nested stack's logical name and the name of the output value in the nested stack in the format Outputs.NestedStackOutputName.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stack.html

Looks like we still cannot reference the stack name more easily. The first answer to the question on this page still stands.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM