Section 4 Main Menu
Overview
https://www.udemy.com/aws-cloudformation-master-class/learn/v4/t/lecture/8162170?start=0
What is Metadata?
- You can use the optional metadata section to include arbitrary YAML that provides details about the template or resources.
Metadata:
Instances:
Description: "Information about the instances"
Databases:
Description: "Information about the databases"
Special metadata keys
- There are 3 metadata keys that have special meaning:
- AWS::CloudFormation::Designer
- Describes how the resources are laid out in your template. This is automatically added by the AWS Designer.
- AWS::CloudFormation::Interface
- Defines grouping and ordering of input paramters when they are displayed in the AWS Console.
- AWS::CloudFormation::Init
- Defines configuration tasks for cfn-init. This is the most powerful usage of the metadata to be discussed in the next section.
- AWS::CloudFormation::Designer
Designer Hands On
https://www.udemy.com/aws-cloudformation-master-class/learn/v4/t/lecture/8162172?start=0
- This is the easiest kind of Metadata. It is automatically generated for you.
- Use it to move item placement or their size in Designer
Metadata:
'AWS::CloudFormation::Designer':
6b0c3e59-...-888dcdb37=da:
size:
width: 60
height: 60
position:
x: 250
y: 250
z: 0
Interface Hands On
- Define grouping and ordering of input parameters when they are displayed in the AWS Console
- This is meant when users must input template parameters manually
- You provide them with grouping, or sorting, that allow them to input parameters efficiently
- Example: Group all the EC2 related parameters together
---
Parameters:
KeyName:
Description: Name of an existing EC2 key pair for SSH access to the EC2 instance.
Type: AWS::EC2::KeyPair::KeyName
InstanceType:
Description: EC2 instance type.
Type: String
Default: t2.micro
AllowedValues:
- t2.micro
- t2.small
- t2.medium
- m3.medium
- m3.large
- m3.xlarge
- m3.2xlarge
SSHLocation:
Description: The IP address range that can SSH to the EC2 instance.
Type: String
MinLength: '9'
MaxLength: '18'
Default: 0.0.0.0/0
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: Must be a valid IP CIDR range of the form x.x.x.x/x.
VPCID:
Description: VPC to operate in
Type: AWS::EC2::VPC::Id
SubnetID:
Description: Subnet ID
Type: AWS::EC2::Subnet::Id
SecurityGroupID:
Description: Security Group
Type: AWS::EC2::SecurityGroup::Id
Resources:
MyEC2Instance:
Type: "AWS::EC2::Instance"
Properties:
AvailabilityZone: us-east-1a
ImageId: ami-a4c7edb2
InstanceType: !Ref InstanceType
SecurityGroups:
- !Ref SecurityGroupID
SubnetID: !Ref SubnetID
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: "Network Configuration"
Parameters:
- VPCID
- SubnetID
- SecurityGroupID
- Label:
default: "Amazon EC2 Configuration"
Parameters:
- InstanceType
- KeyName
ParameterLabels:
VPCID:
default: "Which VPC should this be deployed to?"
Quiz
Metadata is
- Optional
- Mandatory
Metadata can take
- Any value
- One the values AWS::CloudFormation::Designer, ::Interface, ::Init
Metadata is whatever YAML you want, but some values have special meaning in AWS.
