简体   繁体   中英

How do I list existing subnets in a cloudformation template from Amazon?

I am using the template that makes a Multi-AZ lamp stack. The only things I am changing are the existing VPC ID, adding the 2 existing subnets, and naming the RDB database, user and pass. The code validates ok when I click the check button, but when I try to launch the network it fails with the code error, "Template contains errors.: Template format error: Every Description member must be a string."

I have been looking for example SIMPLE templates, that do not use any foo-bar type "everybody knows this is to be filled with their own value" stuff. I have been putting in hours of search and test. This is the first one I have ever done, and it just cannot be all that hard, right? I am using the suggested list of AMIs, though in the future I will put in my customized AMI instead.

"Parameters" : {
    "VpcId" : {
      "Type" : "AWS::EC2::VPC::Id",
      "Description" : "vpc-123456789456",
      "ConstraintDescription" : "must be the VPC Id of an existing Virtual Private Cloud."
},

"Subnets" : {
  "Type" : "List<AWS::EC2::Subnet::Id>",
  "Description" : [
      "subnet-12345621ff4c" ,
      "subnet-1234562188d1"],

This is the only one I have found that doesn't throw errors saying "Expecting a ':' instead of a ','" Should I be listing the name as "List"

"Description" has to be a string. It's a textual description that shows up in the UI when you create the stack.

I think you're looking for either "Default" or "AllowedValues" . The first will set the default value in case your template user doesn't specify anything. To put a list of values, you need to separate them by a comma. For example:

"Parameters": {
    "VpcId": {
        "Type": "AWS::EC2::VPC::Id",
        "Default": "vpc-123456789456",
        "ConstraintDescription": "must be the VPC Id of an existing Virtual Private Cloud."
    },

    "Subnets": {
        "Type": "List<AWS::EC2::Subnet::Id>",
        "Default": "subnet-12345621ff4c,subnet-1234562188d1"
    }
}

The second is a list of allowed values the user can select. That one actually does take a list. For example:

"Parameters": {
    "VpcId": {
        "Type": "AWS::EC2::VPC::Id",
        "AllowedValues": ["vpc-123456789456", "vpc-xxx"],
        "ConstraintDescription": "must be the VPC Id of an existing Virtual Private Cloud."
    }
}

I'm not sure if "ConstraintDescription" will show if the user selects a wrong one. I think that only applies to "AllowedPattern" .

Yes, it can be that hard and very frustrating, but it does get easier over time. The learning curve is steep.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM