Intrinsic functions in AWS CloudFormation are used to assign values to properties that are not available until runtime. Here's a summary of the key intrinsic functions and their uses:
!Ref MyVPC to reference the VPC ID.!GetAtt EC2Instance.AvailabilityZone to get the AZ of an EC2 instance.!ImportValue SSHSecurityGroup to use an exported security group ID.Fn::And, Fn::Equals, Fn::If, Fn::Not, and Fn::Or.RefGetAttFindInMapImportValue
JoinSubForEachToJsonStringCondition Functions (Fn::If, Fn::Not, Fn::Equals, etc.)Base64
CidrGetAZsSelectSplitTransformLengthRef:
Resources:
MySubnet:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref MyVPC
GetAtt:
Resources:
MyEBSVolume:
Type: AWS::EC2::Volume
Properties:
AvailabilityZone: !GetAtt EC2Instance.AvailabilityZone
Base64:
Resources:
MyEC2Instance:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-0abcdef1234567890
InstanceType: t2.micro
UserData:
Fn::Base64: |
#!/bin/bash
echo "Hello, World!" > /home/ec2-user/hello.txt