在嵌套的cloudformation堆栈中上游共享价值? [英] Share Values upstream in a nested cloudformation stack possible?

查看:80
本文介绍了在嵌套的cloudformation堆栈中上游共享价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有某种方法可以将值从子堆栈传递到父堆栈?我所发现的只是传递值,但从不传递值,不幸的是,这与我的堆栈体系结构不符。我可以在eXport / Import中使用交叉引用,但是如果可能的话,宁愿保留嵌套堆栈。

Is there some way to pass on Values form a child stack to a parent stack? All I found was to pass values down, but never up, that would unfortunately not correspond with my stack architecture. I could use cross-referencing with eXport/Import but would rather keep the nested stack if possible.

推荐答案

您肯定可以收集输出

例如:

# 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.

要记住的棘手事情是添加 Outputs 引用 AWS :: CloudFormation :: Stack

The tricky thing to remember is adding the Outputs when referencing the AWS::CloudFormation::Stack.

请注意,这将使 SomeOtherResource 取决于 SomeChildStack ,因此,直到 SomeChildStack SomeOtherResource 才会创建code>已创建。

Note that this will make SomeOtherResource depend on SomeChildStack, so SomeOtherResource won't be created until SomeChildStack has been created.

这篇关于在嵌套的cloudformation堆栈中上游共享价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆