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

问题描述

git blame

我有上面的 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