AWS Ошибка шаблона облачной информации с типами экземпляров EC2 - PullRequest
0 голосов
/ 21 апреля 2020

Я пытаюсь включить опцию Spot Instance в своем шаблоне CloudFormation, который затем добавляю в AWS Каталог услуг.

Я получаю ошибку, касающуюся моего параметра MarketType специально для параметра InstanceMarketOptions и не могу понять, в чем проблема, так как этот параметр прямо из AWS Документации.

Любое направление было бы замечательно. Спасибо

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

  "Description" : "Creates an EC2 instance running the Custom DATA Ubuntu Image",

  "Parameters" : {
    "KeyName": {
      "Description" : "Name of an existing EC2 key pair for SSH access to the EC2 instance.",
      "Type": "AWS::EC2::KeyPair::KeyName"
    },

    "SubnetId": {
      "Type" : "String",
      "Default" : "subnet-0b53e6d08c86dc68d",
      "AllowedValues": ["subnet-0b53e6d08c86dc68d"],
      "Description" : "SubnetId of an existing subnet in your Virtual Private Cloud (VPC)"
    },

    "SecurityGroupId": {
      "Type": "String",
      "Default": "sg-040b93c603129931f",
      "Description":"The SecurityGroupId of an existing EC2 SecurityGroup in your Virtual Private Cloud (VPC)"
    },

    "InstanceType" : {
      "Description" : "EC2 instance type.",
      "Type" : "String",
      "Default" : "m5.large",
      "AllowedValues" : [ "m5.large","m5.xlarge","m5.2xlarge"," m5.4xlarge","m5.8xlarge","m5.12xlarge","m5.16xlarge","p2.xlarge"]
    },

    "InstanceMarketOptions" : {
      "Description" : "EC2 Spot Instance",
      "MarketType" : "spot"
    },

    "SSHLocation" : {
      "Description" : "The IP address range that can SSH to the EC2 instance.",
      "Type": "String",
      "MinLength": "9",
      "MaxLength": "18",
      "Default": "10.0.0.0/8",
      "AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
      "ConstraintDescription": "Must be a valid IP CIDR range of the form x.x.x.x/x."
   }
  },

  "Metadata" : {
    "AWS::CloudFormation::Interface" : {
      "ParameterGroups" : [{
        "Label" : {"default": "Instance configuration"},
        "Parameters" : ["InstanceType", "MarketType"]
      },{
        "Label" : {"default": "Security configuration"},
        "Parameters" : ["KeyName", "SSHLocation"]
      }],
      "ParameterLabels" : {
        "InstanceType": {"default": "Server size:"},
        "KeyName": {"default": "Key pair:"},
        "SSHLocation": {"default": "CIDR range:"},
        "MarketType": {"default": "Spot:"}
      }
    }
  },

  "Mappings" : {
    "AWSRegionArch2AMI" : {
      "us-east-1"      : { "HVM64" : "ami-xxxxxxxxxxxx" }
    }

  },

  "Resources" : {
    "EC2Instance" : {
      "Type" : "AWS::EC2::Instance",
      "Properties" : {
        "InstanceType" : { "Ref" : "InstanceType" },
        "SecurityGroupIds" : [ { "Ref" : "SecurityGroupId" } ],
        "KeyName" : { "Ref" : "KeyName" },
        "MarketType" : {"Ref" : "InstanceMarketOptions" },
        "SubnetId" : { "Ref" : "SubnetId" },
        "ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" }, "HVM64" ] }
      }
    }

  },

  "Outputs" : {
    "PrivateDNSName" : {
      "Description" : "Private DNS name of the new EC2 instance",
      "Value" : { "Fn::GetAtt" : [ "EC2Instance", "PrivateDnsName" ] }
    },
    "PrivateIPAddress" : {
      "Description" : "Private IP address of the new EC2 instance",
      "Value" : { "Fn::GetAtt" : [ "EC2Instance", "PrivateIp" ] }
    }
  }
}

1 Ответ

0 голосов
/ 21 апреля 2020

MarketType - это не то свойство, которое вы можете установить для AWS :: EC2 :: Экземпляр

Самое близкое к тому, что вы ищете, это AWS :: EC2 :: LaunchTemplate LaunchTemplateData с InstanceMarketOptions.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...