Vikas Rathore
Vikas Rathore

Reputation: 8801

How to use List and Map parameters in Cloudformation

In my CloudFormation template, I am having 78 parameters. That is why I am getting an error because we cannot have more than 60 parameters.

I wanted to club some of my parameters into map. Has anyone done this? I am not getting a proper example of how to have parameters in a map then use them in CF template.

Upvotes: 3

Views: 9539

Answers (2)

jbuiss0n
jbuiss0n

Reputation: 467

I don't think you can use a Map as a parameter type. But you can use a CommaDelimitedList instead?

78 paramaters seems to be a lot, can't you use any of the Mappings/Conditions section to ease things for you? Or maybe splitting you stack in multiple smaller dedicated stack, referencing each other using output export/import can be a good solution?

Upvotes: 3

ThomasVdBerge
ThomasVdBerge

Reputation: 8140

Following the AWS documentation

The maps are defined like this:

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

Then you can access them like this:

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

Upvotes: -3

Related Questions