Three level mapping in AWS CloudFormation template

Viewed 422

How can I create and use a three-level map in mappings section in CloudFormation templete?

Fn::FindInMap can be used only for two-level map. Ref: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-findinmap.html

Want to determine resource type based on cellName, domain, and realm. Something like:

Mappings:
  ElastiCacheNodeTypeMapping:
    cell1:
      beta:
        us-east-1: cache.m6g.large
        us-west-2: cache.m6g.large
        eu-west-1: cache.m6g.2xlarge
      prod:
        us-east-1: cache.r6g.24xlarge
    cell2:
      beta:
        us-east-1: cache.m6g.large
        us-west-2: cache.m6g.large
        eu-west-1: cache.m6g.large
      prod:
        us-east-1: cache.r6g.24xlarge
1 Answers

How can I create and use a three-level map

Sadly, you can't. This is not supported as you already noticed. The only way around it could be maybe through CloudFormation macro. You would have to create such a macro, which would take your three-level map, and re-organize it into a valid two-level map for stack deployment.

Related