如何在 Cloudformation 中使用 List 和 Map 参数

How to use List and Map parameters in Cloudformation

在我的 cloudformation 模板中,我有 78 个参数。这就是我收到错误的原因,因为我们不能有超过 60 个参数。

我想将我的一些参数合并到地图中。有没有人这样做过?我没有得到如何在地图中包含参数然后在 CF 模板中使用它们的正确示例。

请指导我。

关注 AWS documentation

地图定义如下:

"RegionMap" : {
  "us-east-1"      : { "32" : "ami-6411e20d", "64" : "ami-7a11e213" },
  "us-west-1"      : { "32" : "ami-c9c7978c", "64" : "ami-cfc7978a" },
  "eu-west-1"      : { "32" : "ami-37c2f643", "64" : "ami-31c2f645" },
  "ap-southeast-1" : { "32" : "ami-66f28c34", "64" : "ami-60f28c32" },
  "ap-northeast-1" : { "32" : "ami-9c03a89d", "64" : "ami-a003a8a1" }
}

然后您可以像这样访问它们:

"Resources" : {
    "myEC2Instance" : {
      "Type" : "AWS::EC2::Instance",
      "Properties" : {
        "ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "32"]},
        "InstanceType" : "m1.small"
      }
    }
  }

我认为您不能使用 Map 作为参数类型。但是您可以改用 CommaDelimitedList 吗?

78个参数好像很多,你就不能用Mappings/Conditions中的任何一个让你省事吗? 或者也许将您的堆栈拆分为多个较小的专用堆栈,使用 output export/import 相互引用可能是一个很好的解决方案?