【问题标题】:AWS CloudFormation EC2 Template getting failedAWS CloudFormation EC2 模板失败
【发布时间】:2018-10-12 21:17:41
【问题描述】:

我试图用我的 AWS 账户中的现有值创建一个 EC2 实例。 CloudFormation 控制台说模板有效。但是当我尝试创建堆栈时,它失败并出现以下错误:

CREATE_FAILED AWS::EC2::Instance Ec2Instance 当前不支持请求的配置。请查看支持配置的文档。**

谁能帮我解决这个错误。我的 CloudFormation 模板如下所示。

谢谢。

AWSTemplateFormatVersion: 2010-09-09
Description: CloudFormation template for creating an ec2 instance
Parameters:
  VPC:
    Description: 'vpc'
    Type: List<AWS::EC2::VPC::Id>
  AvailabilityZone:
    Description: 'test a-z'
    Type: List<AWS::EC2::AvailabilityZone::Name>
  KeyName:
    Description: Key Pair name
    Type: AWS::EC2::KeyPair::KeyName
    Default: kskey-1
  InstanceType:
    Description: 'The instance type for the EC2 instance.'
    Type: String
    Default: t2.micro
    AllowedValues:
    - t2.micro
    - t2.small
    - t2.medium
  Name:
    Description: 'Then name of the EC2 instance'
    Type: String
    Default: 'KS-Test'
  Subnet:
    Description: ' The subnet id'
    Type: String
  SecurityGroups:
    Description: 'The security group'
    Type: List<AWS::EC2::SecurityGroup::Id>
Mappings:
  RegionMap:
    ap-south-1:
      AMI: ami-b46f48db
Resources:
  Ec2Instance:
    Type: 'AWS::EC2::Instance'
    Properties:
      SecurityGroupIds: !Ref SecurityGroups
      KeyName: !Ref KeyName
      ImageId: !FindInMap
        - RegionMap
        - !Ref 'AWS::Region'
        - AMI
      SubnetId: !Ref Subnet

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation


    【解决方案1】:

    这里的问题是您没有在 CloudFormation 模板中定义 EC2 实例类型。您在“参数”部分而不是“资源”部分中定义了它。添加它将为您解决问题。

    您遇到的问题是,如果您不指定实例类型,CloudFormation 将选择默认值m3.medium。这是旧实例类型,已推出新一代实例(m5 系列)。

    将以下行添加到 CloudFormation 模板的末尾:

    InstanceType: !Ref InstanceType
    

    参考资料:

    • 可以在here找到m5系列文档。
    • 可以在here找到实例类型的CloudFormation默认值。

    【讨论】:

    • 非常感谢您的回复。成功了。
    猜你喜欢
    • 2020-11-01
    • 1970-01-01
    • 2021-12-29
    • 2020-11-24
    • 2020-08-03
    • 2014-05-29
    • 2018-04-05
    • 1970-01-01
    • 2019-09-22
    相关资源
    最近更新 更多