プロパティの指定は多岐に渡るため、細かい指定を暗記する必要はありません。
公式ドキュメントを検索し、素早く読み解けるようになることが重要です。
Resources:
MyVPC2:
Type: "AWS::EC2::VPC"
Properties:
CidrBlock: "10.0.8.0/21"
EnableDnsSupport: true
EnableDnsHostnames: true
Tags:
- Key: Name
Value: "MyVPCfromCF"
subnetName:
Type: "AWS::EC2::Subnet"
Properties:
AvailabilityZone: "ap-northeast-1a"
VpcId: !Ref MyVPC2
CidrBlock: "10.0.8.0/24"
Tags:
- Key: Name
Value: "subnet1fromCF"
secGroupName:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupName: "GroupName-SG"
GroupDescription: "GroupDescription-SG"
VpcId: !Ref MyVPC2
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: "0.0.0.0/0"
Tags:
- Key: Name
Value: "SGfromCF"
Outputs:
Subnet1:
Value: !Ref subnetName
Export:
Name: Subnet1Name
SG1:
Value: !Ref secGroupName
Export:
Name: SG1Name
AWSTemplateFormatVersion: "2010-09-09"
Resources:
myEC2Instance:
Type: "AWS::EC2::Instance"
Properties:
KeyName: Mykeypair
ImageId: インスタンスID
InstanceType: t2.micro
Monitoring: false
SecurityGroupIds:
- !ImportValue SG1Name
SubnetId: !ImportValue Subnet1Name
Tags:
- Key: Name
Value: CFec2
AWSTemplateFormatVersion: "2010-09-09"
Resources:
myEC2Instance:
Type: "AWS::EC2::Instance"
Properties:
KeyName: Mykeypair
ImageId: インスタンスID
InstanceType: t2.micro
Monitoring: false
SecurityGroupIds:
- !ImportValue SG1Name
SubnetId: !ImportValue Subnet1Name
Tags:
- Key: Name
Value: CFec2