Amazon cloudformation 是否可以在嵌套的cloudformation堆栈中共享上游值?
是否有某种方法将值从子堆栈传递到父堆栈?我所发现的只是向下传递值,而不是向上传递值,不幸的是,这与我的堆栈架构不符。我可以在导出/导入时使用交叉引用,但如果可能的话,我宁愿保留嵌套堆栈。您肯定可以从子堆栈收集输出的值,并在父堆栈中使用它们 例如:Amazon cloudformation 是否可以在嵌套的cloudformation堆栈中共享上游值?,amazon-cloudformation,Amazon Cloudformation,是否有某种方法将值从子堆栈传递到父堆栈?我所发现的只是向下传递值,而不是向上传递值,不幸的是,这与我的堆栈架构不符。我可以在导出/导入时使用交叉引用,但如果可能的话,我宁愿保留嵌套堆栈。您肯定可以从子堆栈收集输出的值,并在父堆栈中使用它们 例如: # parent stack AWSTemplateFormatVersion: 2010-09-09 Resources: SomeChildStack: Type: AWS::CloudFormation::Stack Prop
# parent stack
AWSTemplateFormatVersion: 2010-09-09
Resources:
SomeChildStack:
Type: AWS::CloudFormation::Stack
Properties:
Parameters:
AWS CloudFormation Stack Parameters
TemplateURL: !Ref SomeTemplateUrl
SomeOtherResource:
Type: AWS::AnyOther::Resources
Properties:
SomeProperty: !Ref SomeChildStack.Outputs.MyOutput
在SomeChildStack
中:
# The template used for SomeChildStack
AWSTemplateFormatVersion: 2010-09-09
Resources:
S3Bucket:
Type: AWS::S3::Bucket
Properties:
AccessControl: PublicRead
LoggingConfiguration:
DestinationBucketName: !Ref 'LoggingBucket'
LogFilePrefix: testing-logs
Outputs:
MyOutput:
Value: !Ref 'S3Bucket'
Description: Name of the sample Amazon S3 bucket.
要记住的一件棘手的事情是在引用时添加输出
请注意,这将使SomeOtherResource
依赖于SomeChildStack
,因此在创建SomeChildStack
之前不会创建SomeOtherResource
。这不会在堆栈之间创建某种循环引用吗?每一个都必须部署,另一个才能导入值我尝试了@aerioeus方式,但没有成功!然后我改变了!参考中的!GetAtt
它工作了<代码>!GetAtt[SomeChildStack,Outputs.MyOutput]
Merci,那么在SomeotherResource中添加DependOn是否有意义呢?在这种情况下没有。使用时!Ref
在SomeOtherResource
中,有一个,因此添加DependsOn
是没有必要的。谢谢,我不知道。