Dependencies Between Nested Stack [Stack 2 depend on Exported value from Stack 1]

0

How do i resolve depenecies form stack 1 in stack 2 Nested Stack Based on Imported Value form Stack 1

# Stack 1: Create S3 bucket and export its name
Resources:
  MyBucket:
    Type: AWS::S3::Bucket
    ...
  ExportBucketName:
    Value: !Ref MyBucket
    Export:
      Name: MyBucketName

# Stack 2: Create EC2 instance and reference S3 bucket
Resources:
  MyInstance:
    Type: AWS::EC2::Instance
    DependsOn: [Make it dependen on the exported value from stack 1 ExportBucketName]
    Properties:
      ...
      S3BucketName: !ImportValue MyBucketName
1 Answer
1
Accepted Answer

Hi,

Look at this page: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/walkthrough-crossstackref.html

You have working examples with corresponding CFN templates in steps 1 & 2 to understand fully how you cross-reference between stacks.

Best,

Didier

profile pictureAWS
EXPERT
answered 8 months ago
profile picture
EXPERT
reviewed 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions