Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon cloudformation 是否可以在嵌套的cloudformation堆栈中共享上游值?_Amazon Cloudformation - Fatal编程技术网

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
是没有必要的。谢谢,我不知道。