Carlos Aguni

Highly motivated self-taught IT analyst. Always learning and ready to explore new skills. An eternal apprentice.


AWS SAM, CloudFormation Notes

06 Jul 2020 » aws

Ref Resource Attribute on another template

https://medium.com/@anupam.ncsu/reference-resource-from-one-cloud-formation-stack-in-another-during-formation-f5c80679f0fd

Outputs:
    VPCId:
        Description: VPC ID
        Value:
          Ref: VPC
        Export:
          Name:
            Fn::Sub: "${AWS::StackName}-VPCID" # <-----------------
Parameters:
  NetworkStackName:
    Description: Name of the base stack with all infra resources
    Type: String
    Default: BaseStack # <------- ${AWS::StackName} from the other Cloudformation template
    
Resources:
  WebServerInstance:
    Type: AWS::EC2::Instance
    Properties:
      InstanceType: t2.micro
      ImageId:
   - SOMETHING FROM MY REGION
      NetworkInterfaces:
      - GroupSet:
        - Fn::ImportValue:
            Fn::Sub: "${NetworkStackName}-SecurityGroupID" # <---------------