Вы можете определенно собрать выходные значения из дочернего стека и использовать их в родительском стеке.
Например:
# 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
.
Обратите внимание, что это сделает SomeOtherResource
зависимым от SomeChildStack
, поэтому SomeOtherResource
не будет создан, пока не будет создан SomeChildStack
.