下述yml文件简单配置了Stack模板,
Resources: #Resources节点在模板中必不可少
MyEC2Instance:
Type: AWS::EC2::Instance
Properties:
ImageId: !Ref ImageIdParameter
KeyName: !Ref KeyNameParameter
InstanceType: !Ref InstanceTypeParameter
SecurityGroupIds:
- !Ref MySecurityGroup
MySecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Enable http to host
SecurityGroupIngress:
-
IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: 0.0.0.0/0
-
IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
Parameters:
ImageIdParameter:
Type: String
Default: ami-id
Description: Enter ami id
KeyNameParameter:
Type: String
Default: keypair
Description: Enter key name
InstanceTypeParameter:
Type: String
Default: t2.micro
AllowedValues:
- t2.micro
- m1.small
- m1.large