【问题标题】:cloudformation, error creating a change: set Parameter 'ami' must be one of AllowedValuescloudformation,创建更改时出错:设置参数“ami”必须是 AllowedValues 之一
【发布时间】:2022-01-20 00:27:59
【问题描述】:

我正在尝试在 CloudFormation 中创建一个堆栈。当我完成该过程并填充字段时,系统会要求我输入 AMI。

我键入实例 ID,但在下一个屏幕上我收到以下错误消息:

There was an error creating this change set Parameter 'ami' must be one of AllowedValues

我不确定这里需要什么类型的参数。除了 ID 我还应该输入什么?

查看 AMI 详细信息,我看到 AMI 设置为私有。它不与任何帐户或组织共享。这就是它不起作用的原因吗?

我尝试用谷歌搜索该错误消息,但没有找到任何相关信息。

谢谢

模板:

{

  "AWSTemplateFormatVersion" : "2010-09-09",

  "Description" : "Template to create a Ubuntu grafana server",

  "Parameters": {

    "instanceName": {

      "Description": "Ubuntu Grafana",

      "Type": "String"

    },

    "Subnet": {
c
      "Description": "The subnets where the instance is created.",

      "Type": "AWS::EC2::Subnet::Id"

    },

    "securitygroup": {

      "Description": "The subnets where workers can be created.",

      "Type": "List<AWS::EC2::SecurityGroup::Id>"

    },

    "InstanceType": {

      "Description": "EC2 instance type for the node instances",

      "Type": "String",

      "Default": "t3.micro",

      "AllowedValues": [

        "t3.micro", "t3.small", "t2.medium"

      ],

      "ConstraintDescription": "Must be a valid EC2 instance type"

    },

    "KeyName": {

      "Description": "The EC2 Key Pair to allow SSH access to the instances",

      "Type": "AWS::EC2::KeyPair::KeyName"

    },

    "volumeSize": {

      "Description": "Size of EBS volume in GB",

      "Type": "Number"

    },

    "ami" : {

      "Description": "ami of instance",

      "Type" : "AWS::EC2::Image::Id",

      "AllowedValues" : [

        "ami-00000000","ami-00000000", "ami-00000000"

      ]

    }

  },

  "Resources" : {

    "masterinstance" : {

      "Type" : "AWS::EC2::Instance",

      "Properties" : {

        "BlockDeviceMappings" : [ {

          "DeviceName" :  "/dev/sda1",

          "Ebs" : {

            "DeleteOnTermination" : "False",

            "Encrypted" : "False",

            "VolumeSize" : {"Ref":  "volumeSize"},

            "VolumeType" : "gp2"

          }

        }],

        "ImageId" : {"Ref": "ami"},

        "InstanceType" : {"Ref" : "InstanceType"},

        "KeyName" : {"Ref": "KeyName"},

        "SecurityGroupIds" : {"Ref" :  "securitygroup"},

        "SubnetId" : {"Ref": "Subnet"},

        "Tags" : [ {

          "Key" : "Name",

          "Value" : {"Ref": "instanceName"}

        } ]

      }

    }

  }

}

【问题讨论】:

  • 请分享 CloudFormation 模板,或至少部分内容
  • 我刚弄好了,谢谢你的帮助@Paolo
  • 您的问题不清楚。您希望用户输入 AMI ID 还是希望用户从一组 ID 中进行选择?
  • 您可以在模板中找到“AllowedValues”并使用列表中的值。也许你没有提供真实的。

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


【解决方案1】:
    "ami" : {

      "Description": "ami of instance",

      "Type" : "AWS::EC2::Image::Id",

      "AllowedValues" : [

        "ami-00000000","ami-00000000", "ami-00000000"

      ]

    }

您作为ami 参数的值提供的任何值都必须是AllowedValues 之一。由于 AllowedValues 中的所有 ID 都是无效的,因此可以安全地假设您没有提供这些值之一。删除 AllowedValues 约束(或更正列表)将解决此问题:

    "ami" : {

      "Description": "ami of instance",

      "Type" : "AWS::EC2::Image::Id"

    }

【讨论】:

  • 谢谢...我在发帖后不久就想通了..在您花时间回答时仍然给您指出:) 非常感谢!
猜你喜欢
  • 2019-01-19
  • 2016-08-13
  • 1970-01-01
  • 2016-05-03
  • 2020-02-02
  • 2020-12-10
  • 2015-09-14
  • 1970-01-01
  • 2020-01-23
相关资源
最近更新 更多