属性安全组的值必须是字符串列表类型


Parameters:
KeyName:
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
Type: 'AWS::EC2::KeyPair::KeyName'
ConstraintDescription: must be the name of an existing EC2 KeyPair.
MySubnet:
Description: My subnet from my VPC
Type: 'AWS::EC2::Subnet::Id'
Default: subnet-YYYYYYYY

MySG:
Description: My Security Group from my VPC
Type: 'AWS::EC2::SecurityGroup::GroupName'
Default: SG-YYYYYYYY

Resources:
Ec2Instance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: ami-09e67e426f25ce0d7
SecurityGroups: !Ref MySG
SubnetId: !Ref MySubnet

KeyName: !Ref KeyName


我有上面的cloudformation模板代码;属性SecurityGroups的值必须是类型List of String";,我的vpc和安全组在不同的cloudformation模板中得到了简化,我想在特定的安全组中启动ec2。

SecurityGroups必须是字符串列表,如错误所示。因此,正确的模板是:

Resources:
Ec2Instance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: ami-09e67e426f25ce0d7
SecurityGroups: 
- !Ref MySG
SubnetId: !Ref MySubnet
KeyName: !Ref KeyName

最新更新