Del*_*ton 1 amazon-ec2 amazon-web-services aws-cloudformation
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
Run Code Online (Sandbox Code Playgroud)
我有上面的 cloudformation 模板代码,它返回“属性 SecurityGroups 的值必须是字符串列表类型”,我的 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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2158 次 |
| 最近记录: |