繁体   English   中英

如何在亚马逊的云信息模板中列出现有子网?

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

我正在使用制作多AZ灯堆栈的模板。 我要改变的唯一事情是现有的VPC ID,添加2个现有的子网,并命名RDB数据库,用户和传递。 单击检查按钮时代码验证正常,但是当我尝试启动网络时,它失败并出现代码错误,“模板包含错误:模板格式错误:每个描述成员必须是一个字符串。”

我一直在寻找示例SIMPLE模板,不使用任何foo-bar类型“每个人都知道这是填充自己的价值”的东西。 我一直在进行数小时的搜索和测试。 这是我做过的第一次,它不是那么难,对吧? 我正在使用建议的AMI列表,但将来我会放入我自定义的AMI。

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

这是我发现的唯一一个没有抛出错误的错误,说“期待':'而不是','”我应该将名称列为“列表”

"Description"必须是一个字符串。 这是在创建堆栈时在UI中显示的文本描述。

我认为你正在寻找"Default""AllowedValues" 第一个将设置默认值,以防模板用户未指定任何内容。 要放置值列表,您需要用逗号分隔它们。 例如:

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

第二个是用户可以选择的允许值列表。 那个人确实拿了一份清单。 例如:

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

我不确定"ConstraintDescription"是否会显示用户是否选择了错误的一个。 我认为这仅适用于"AllowedPattern"

是的,它可能很难但非常令人沮丧,但随着时间的推移它会变得更容易。 学习曲线陡峭。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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