ImportValue

The import_value method is the CloudFormation Fn::ImportValue equivalent.

Example Snippet

resource(:instance, "AWS::EC2::Instance",
  instance_type: ref(:instance_type),
  image_id: "ami-0de53d8956e8dcf80",
  network_interfaces: {
    group_set: [import_value(sub("${NetworkStack}-SecurityGroupID"))],
    associate_public_ip_address: "true",
    device_index: "0",
    delete_on_termination: "true",
    subnet_id: import_value(sub("${NetworkStack}-SubnetID"))
  }
)

Example Output

Resources:
  Instance:
    Type: AWS::EC2::Instance
    Properties:
      InstanceType:
        Ref: InstanceType
      ImageId: ami-0de53d8956e8dcf80
      NetworkInterfaces:
        GroupSet:
        - Fn::ImportValue:
            Fn::Sub:
            - "${NetworkStack}-SecurityGroupID"
            - {}
        AssociatePublicIpAddress: 'true'
        DeviceIndex: '0'
        DeleteOnTermination: 'true'
        SubnetId:
          Fn::ImportValue:
            Fn::Sub:
            - "${NetworkStack}-SubnetID"
            - {}

Back to Intrinsic Functions List.

Pro tip: Use the <- and -> arrow keys to move back and forward.

Edit this page

See a typo or an error? You can improve this page. This website is available on GitHub and contributions are encouraged and welcomed. We love pull requests from you!