首页 > 解决方案 > Cloud Formation 无法使用 VPCIdNotSpecified 创建安全组

问题描述

问题 :

使用云形成模板创建安全组时,即使我提供了 VPCID 作为输入,它也会失败并出现 VPCIdNotSpecified 错误。

错误消息: 此用户没有默认 VPC(服务:AmazonEC2;状态代码:400;错误代码:VPCIdNotSpecified;请求 ID:d45efd39-16ce-4c0c-9e30-746b39f4ff44;代理:null)

背景: 我已经删除了账户自带的默认 VPC,并创建了自己的 VPC。另外,我将 VPC ID 作为参数输入。\1/使用 aws cli 验证模板及其良好。所有输入参数均已正确获取并显示在云形成创建的摘要页面中。它甚至显示匹配的 VPCID。

代码 :

Parameters:
 VPCName:
    Description: Enter the VPC that you want to launch the instance
    Type : AWS::EC2::VPC::Id
    ConstraintDescription: VPC must be already existing
Resources:
 HANASG:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupName: XSASG
      GroupDescription: This will allow connections between your RDP instance & HANA Box
      **VpcId: !Ref VPCName**
      SecurityGroupIngress:
        - IpProtocol: tcp
          SourceSecurityGroupName: !Ref RdpSgName
          FromPort: 0
          ToPort: 65535
      SecurityGroupEgress:
        - IpProtocol: tcp
          FromPort: 0
          ToPort: 65535
          CidrIp: 0.0.0.0/0
      Tags:
        - Key: Name
          Value: HANAXSASG```

标签: amazon-web-servicesamazon-ec2amazon-cloudformationamazon-vpc

解决方案


我建议按照亚马逊的说明在控制台的 VPC 部分重新创建默认 VPC 。最好不要使用默认 VPC,而是按照您的描述创建和配置您自己的 VPC。在内部,默认 VPC 有一些特殊之处,未通过控制台或 API 公开。我怀疑这是您问题的根本原因,创建一个新的默认 VPC 应该可以解决它。

AFAIK 重命名默认 VPC 没有问题(我的名为Default VPC - DO NOT USE)。


推荐阅读