Sub

The sub method is the CloudFormation Fn::Sub equivalent.

Example Snippet

resource(:instance, "AWS::EC2::Instance",
  instance_type: ref(:instance_type),
  image_id: "ami-0de53d8956e8dcf80",
  user_data: sub("hello ${k1} ${k2}", k1: "v1", k2: "v2")
)

Example Output

Resources:
  Instance:
    Type: AWS::EC2::Instance
    Properties:
      InstanceType:
        Ref: InstanceType
      ImageId: ami-0de53d8956e8dcf80
      UserData:
        Fn::Sub:
        - hello ${k1} ${k2}
        - k1: v1
          k2: v2

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!