【问题标题】:Cloudformation: "No default VPC for this user. GroupName is only supported for EC2-Classic and default VPC"Cloudformation:\“此用户没有默认 VPC。GroupName 仅支持 EC2-Classic 和默认 VPC\”
【发布时间】:2022-09-30 19:27:32
【问题描述】:

我正在尝试使用 Cloudformation 部署 EC2 实例,但出现以下错误:

No default VPC for this user. GroupName is only supported for EC2-Classic and default VPC

尽管在安全组上明确设置了 vpc:

\"InstanceSecurityGroup\" : {
      \"Type\" : \"AWS::EC2::SecurityGroup\",
      \"Properties\" : {
        \"GroupName\": \"SG-AD-TSDB\",
        \"GroupDescription\" : \"Enable SSH access via port 22\",
        \"VpcId\": \"vpc-<private>\",
        \"SecurityGroupIngress\" : [ {
          \"IpProtocol\" : \"tcp\",
          \"FromPort\" : \"22\",
          \"ToPort\" : \"22\",
          \"CidrIp\" : { \"Ref\" : \"SSHLocation\"}
        } ]
      }
    }

我不知道如何处理这个错误。

  • 你能提供更多的模板吗?我不认为错误源于您发布的代码。它的来源必须在其他地方。

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


【解决方案1】:

我相信GroupName 是用于老式 VPC 的传统道具。删除它,SG 列表中的名称字段似乎是从我的云中的GroupDescription 复制的。

【讨论】:

    【解决方案2】:

    我得到了同样的错误。

    我不知道真正的原因,尽管删除默认 VPC 并重新创建它解决了我的问题。

    如果您无法删除默认 VPC,则应使用管理员帐户来执行此操作。

    【讨论】:

      【解决方案3】:

      正如Marcin 评论的那样,我相信问题出在AWS::EC2::Instance 声明中。我也遇到了这个错误,只有在将SubnetId 属性添加到实例的NetworkInterfaces 属性之后,我才能成功部署堆栈而没有错误。

      完整的 yaml 代码是:

      ---
      AWSTemplateFormatVersion: '2010-09-09'
      Description: Deploy a simple Amazon Linux Instance and allow SSH connectivity.
      Parameters:
        KeyName:
          Description: EC2 Key Pair for SSH Access, you must have created these prior to
            running this.
          Type: AWS::EC2::KeyPair::KeyName
        VpcId:
          Description: 'Please insert one of your VPC ID. you can find this info in the
            VPC console '
          Type: AWS::EC2::VPC::Id
      
        ImageId:
          Description: 'Please insert an Image ID of the AMI you want to use. Leave the field unchanged to use the default Amazon Linux AMI'
          Type: String
          Default: ami-05ff5eaef6149df49
        SubnetId:
          Description: 'Please choose a Subnet Id'
          Type: AWS::EC2::Subnet::Id
      
      Resources:
        SimpleInstance:
          Type: AWS::EC2::Instance
          Properties:
            KeyName:
              Ref: KeyName
            InstanceType: t2.micro
            ImageId: !Ref ImageId
            NetworkInterfaces:
            - GroupSet:
              - Ref: SimpleInstanceSg
              SubnetId: 
                Ref: SubnetId
              AssociatePublicIpAddress: true
              DeviceIndex: '0'
              DeleteOnTermination: true
        SimpleInstanceSg:
          Type: AWS::EC2::SecurityGroup
          Properties:
            GroupDescription: Enable SSH access via port 22
            VpcId:
              Ref: VpcId
            SecurityGroupIngress:
            - IpProtocol: tcp
              FromPort: 22
              ToPort: 22
              CidrIp: 0.0.0.0/0
      

      原始代码(没有 SubnetId 声明)取自 here

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-12-14
        • 2018-09-01
        • 1970-01-01
        • 2020-01-31
        • 2020-03-27
        • 1970-01-01
        • 2021-06-28
        • 2021-12-02
        相关资源
        最近更新 更多