【问题标题】:value of property security group must be of type list of string属性安全组的值必须是字符串列表类型
【发布时间】:2021-08-06 12:49:09
【问题描述】:
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 的值必须是字符串类型列表”,我的 vpc 和安全组在不同的 cloudformation 模板中进行了简化,我想在特定的安全性中启动 ec2组。

【问题讨论】:

    标签: amazon-web-services amazon-ec2 amazon-cloudformation


    【解决方案1】:

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

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

    【讨论】:

    • 没问题,我们将不胜感激!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-06
    • 2021-12-05
    • 1970-01-01
    • 2020-03-25
    • 1970-01-01
    • 2020-07-14
    • 2019-03-16
    相关资源
    最近更新 更多