【问题标题】:AWS Cloud Formation - Requested configuration not supported AWS::EC2::InstanceAWS Cloud Formation - 不支持请求的配置 AWS::EC2::Instance
【发布时间】:2018-06-27 05:07:13
【问题描述】:

我的一个云形成模板出现以下错误 -

13:00:10 UTC+0550 CREATE_FAILED AWS::EC2::Instance WebApplicationServer 当前不支持请求的配置。请查看支持配置的文档。

我的 CloudFormation 模板是 -

{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
    "DevServerKeyPair": {
        "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."
    }
},
"Resources": {
    "DevVpc": {
        "Type": "AWS::EC2::VPC",
        "Properties": {
            "CidrBlock": "172.31.0.0/16",
            "EnableDnsSupport": "false",
            "EnableDnsHostnames": "false",
            "InstanceTenancy": "dedicated",
            "Tags": [
                {
                    "Key": "Name",
                    "Value": "DevStackVpc"
                }
            ]
        }
    },
    "DevSubnet": {
        "Type": "AWS::EC2::Subnet",
        "Properties": {
            "VpcId": {
                "Ref": "DevVpc"
            },
            "CidrBlock": "172.31.0.0/16",
            "AvailabilityZone": {
                "Fn::Select": [
                    0,
                    {
                        "Fn::GetAZs": ""
                    }
                ]
            }
        }
    },
    "WebApplicationServerSG": {
        "Type": "AWS::EC2::SecurityGroup",
        "Properties": {
            "VpcId": {
                "Ref": "DevVpc"
            },
            "GroupDescription": "Enable HTTP, HTTPS and SSH access",
            "Tags": [
                {
                    "Key": "Name",
                    "Value": "WebApplicationServer Service Group"
                }
            ],
            "SecurityGroupIngress": [
                {
                    "IpProtocol": "tcp",
                    "FromPort": "443",
                    "ToPort": "443",
                    "CidrIp": "0.0.0.0/0"
                },
                {
                    "IpProtocol": "tcp",
                    "FromPort": "80",
                    "ToPort": "80",
                    "CidrIp": "0.0.0.0/0"
                },
                {
                    "IpProtocol": "tcp",
                    "FromPort": "22",
                    "ToPort": "22",
                    "CidrIp": "0.0.0.0/0"
                }
            ],
            "SecurityGroupEgress": [
                {
                    "IpProtocol": "tcp",
                    "FromPort": "443",
                    "ToPort": "443",
                    "CidrIp": "0.0.0.0/0"
                },
                {
                    "IpProtocol": "tcp",
                    "FromPort": "80",
                    "ToPort": "80",
                    "CidrIp": "0.0.0.0/0"
                },
                {
                    "IpProtocol": "tcp",
                    "FromPort": "22",
                    "ToPort": "22",
                    "CidrIp": "0.0.0.0/0"
                }
            ]
        }
    },
    "WebApplicationServer": {
        "Type": "AWS::EC2::Instance",
        "Properties": {
            "ImageId": "ami-f3e5aa9c",
            "InstanceType": "t2.micro",
            "Tags": [
                {
                    "Key": "Name",
                    "Value": "WebApplicationServer"
                }
            ],
            "KeyName": {
                "Ref": "DevServerKeyPair"
            },
            "NetworkInterfaces": [
                {
                    "SubnetId": {"Ref": "DevSubnet"},
                    "AssociatePublicIpAddress": "true",
                    "DeviceIndex": "0",
                    "GroupSet": [{ "Ref" : "WebApplicationServerSG" }]
                }
            ]
        }
    }
  }
}

我尝试对其进行诊断,但无法理解当前不支持此简单模板中的哪些特定配置。任何帮助或指针将不胜感激。

【问题讨论】:

  • 您是否可以使用此处使用的 ami-id 直接启动实例?基本上与模板中指定的配置相同。

标签: amazon-web-services amazon-ec2 amazon-cloudformation aws-security-group


【解决方案1】:

就我而言,我没有专门的租赁。原因是我尝试使用太新的实例类型 (r6g) 并且在我的区域中丢失。所以解决方案是回退到旧版本 (r5a)。

【讨论】:

    【解决方案2】:

    您的 VPC 具有专用的实例租期,但 t2 实例无法以 dedicated instances 启动。您将需要选择不同的实例类型或切换 VPC 的租期。

    【讨论】:

      【解决方案3】:

      使用 fn::select 函数创建子网时看起来有问题。

      "DevSubnet" : {
        "Type" : "AWS::EC2::Subnet",
        "Properties" : {
          "VpcId" : { "Ref" : "DevVpc" },
          "CidrBlock" : "172.31.0.0/16",
          "AvailabilityZone" : {
            "Fn::Select" : [ "0", { "Fn::GetAZs" :""} ]
          }
        }
      }
      

      试试这个。我希望它会起作用。

      【讨论】:

      • 除了将整个select函数放在一行之外没有区别,两者都是有效的json语法因此没有区别。
      猜你喜欢
      • 1970-01-01
      • 2020-07-17
      • 1970-01-01
      • 2018-03-05
      • 1970-01-01
      • 2013-03-01
      • 2018-03-12
      • 2015-06-30
      • 2019-04-04
      相关资源
      最近更新 更多