【问题标题】:How to fix cloudformation template which creates EC2 along with AWS::CloudFormation::Init如何修复与 AWS::CloudFormation::Init 一起创建 EC2 的 cloudformation 模板
【发布时间】:2019-09-22 21:32:29
【问题描述】:

我正在使用 cloudformation 模板部署堆栈,该模板使用 cloud-init 部分创建 EC2。当我部署它时,我收到以下错误消息:

The following resource(s) failed to create: [EC2Instance]. . The requested configuration is currently not supported. Please check the documentation for supported configurations.

如果我删除“元数据”部分,一切正常并创建一个 EC2。元数据部分可能配置错误,我无法弄清楚是什么。

我将此文档用作参考 -> https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html

AWSTemplateFormatVersion: 2010-09-09
Resources:
  EC2Instance:
    Type: 'AWS::EC2::Instance'
    Metadata: 
      AWS::CloudFormation::Init: 
        configSets: 
          config: 
            - "config1"
            - "config2"
        config1: 
          commands: 
            test: 
              command: "echo \"hello from config 1\" > test.txt"
        config2: 
          commands: 
            test: 
              command: "echo \"hello from config 2\" > test.txt"
    Properties:
      InstanceType: "t2.small"
      ImageId: "ami-06b382aba6c5a4f2c"
      SecurityGroupIds:
        - "sg-123456"
      SubnetId: "subnet-123456"
      KeyName: "my-example-key"

我希望创建 EC2 实例,但我收到以下错误消息:

The requested configuration is currently not supported. Please check the documentation for supported configurations. (Service: AmazonEC2; Status Code: 400; Error Code: Unsupported; Request ID: --Redacted--)

【问题讨论】:

  • @AlexHarvey 是的,这就是整个模板。堆栈是否为您成功创建?
  • @AlexHarvey 就是这么做的。那也没有用:(
  • @AlexHarvey 什么对我有用:如果我删除“元数据”部分并保持其他所有内容完好无损,它也可以工作(即使 EBS 和 IAM 位在我的原始文件中完好无损)模板)什么不起作用:如果我添加“元数据”部分,则无法创建 EC2
  • 谢谢。我再次对其进行了编辑,以仅显示我认为的 minimal, complete, verifiable 示例。你能检查我最简单的版本是否也会产生错误吗?

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


【解决方案1】:

此处使用的 AMI 是 ami-06b382aba6c5a4f2c,适用于 64 位 Arm。实例类型族为 t2。 ami-06b382aba6c5a4f2c 支持的实例系列是 a1。

如果您想使用 AMZ linux 2,请使用为 64 位 (x86) 架构构建的 AMI ami-0de53d8956e8dcf80。

简而言之,将 ImageId 更改为 'ami-0de53d8956e8dcf80'

希望这会有所帮助..

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-12
    • 1970-01-01
    • 2019-10-25
    • 2019-12-29
    • 1970-01-01
    • 2019-12-28
    • 2020-03-07
    • 2019-10-23
    相关资源
    最近更新 更多