Articles → AWS → Import And Export Data Between The Stacks In AWS CloudFormation

Import And Export Data Between The Stacks In AWS CloudFormation






Scenario







Stack Creation




{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Metadata": {
    "AWS::CloudFormation::Designer": {
      "2dc4ba2f-ea15-4070-8c8e-4292600d411f": {
        "size": {
          "width": 60,
          "height": 60
        },
        "position": {
          "x": 523,
          "y": 122
        },
        "z": 0
      }
    }
  },
  "Resources": {
    "S3B33CKD": {
      "Type": "AWS::S3::Bucket",
      "Properties": {
        "BucketName": "gs-sourcebucket"
      },
      "Metadata": {
        "AWS::CloudFormation::Designer": {
          "id": "2dc4ba2f-ea15-4070-8c8e-4292600d411f"
        }
      }
    }
  },
  "Outputs": {
    "bucketname1": {
      "Description": "gs-source1bucket",
      "Value": "gs-source1bucket",
      "Export": {
        "Name": "gyansangrahbucketname"
      }
    }
  }
}






Picture showing the value exported from stack
Click to Enlarge



{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Metadata": {
    "AWS::CloudFormation::Designer": {
      "2dc4ba2f-ea15-4070-8c8e-4292600d411f": {
        "size": {
          "width": 60,
          "height": 60
        },
        "position": {
          "x": 523,
          "y": 122
        },
        "z": 0
      }
    }
  },
  "Resources": {
    "S3B33CKD": {
      "Type": "AWS::S3::Bucket",
      "Properties": {
        "BucketName": { "Fn::ImportValue": "gyansangrahbucketname" }
      },
      "Metadata": {
        "AWS::CloudFormation::Designer": {
          "id": "2dc4ba2f-ea15-4070-8c8e-4292600d411f"
        }
      }
    }
  }  
}




{ "Fn::ImportValue": "gyansangrahbucketname" }


Picture showing the second stack created from the imported values
Click to Enlarge


Output




Picture showing the bucket created from imported values from stack
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, January 4, 2022

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250