Fn::Sub
文字列と変数を組み合わせる際に使用する。
Parameters: EnvironmentName: Type: String Default: my-app Resources: Subnet1: Type: AWS::EC2::Subnet Properties: ... Tags: - Key: Name Value: !Sub ${EnvironmentName}-1
Ref
指定したパラメータまたはリソースの値を取得する際に使用する。
・パラメータの値を取得。
Parameters: VpcCIDR: Type: String Default: 10.1.0.0/16 Resources: VPC: Type: AWS::EC2::VPC Properties: CidrBlock: !Ref VpcCIDR ...
・リソースの値を取得。
Parameters: ... Resources: VPC: Type: AWS::EC2::VPC ... InternetGateway: Type: AWS::EC2::InternetGateway ... InternetGatewayAttachment: Type: AWS::EC2::VPCGatewayAttachment Properties: InternetGatewayId: !Ref InternetGateway VpcId: !Ref VPC