amazon-web-services - cloudformation,创建更改时出错 : set Parameter 'ami' must be one of AllowedValues

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

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

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

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

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

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

我尝试在 Google 上搜索该错误消息,但没有找到任何相关内容。

谢谢

模板:

{

  "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"}

        } ]

      }

    }

  }

}

最佳答案

    "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"

    }

关于amazon-web-services - cloudformation,创建更改时出错 : set Parameter 'ami' must be one of AllowedValues,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70774064/

相关文章:

java - 建立 AWS 连接时 Android 中出现 ClassDefNotFound 错误

ruby-on-rails - 在Rails中缓存动态生成的图像

node.js - 放大初始化错误 - ✖ 根堆栈创建失败初始化失败 TypeError : Cannot redefine property: default

amazon-web-services - 使用 CommaDelimitedList 参数时 Fn::Equals 抛出错误

amazon-web-services - 如果资源创建已存在于无服务器中,如何忽略资源创建

amazon-web-services - 克隆 EC2 Ubuntu 实例

amazon-web-services - 使用yum在Amazon Linux 2中安装.NET Core

amazon-web-services - AWS 相当于 Firebase 实时数据库的是什么?

parameters - Cloudformation 参数传递到模板失败

c# - 使用 C# SDK 创建 Amazon AMI,但仅包含根卷