
- Fn::FindInMap performs a static lookup at stack creation or update.
- It requires three arguments: the mapping name, the top-level key (row), and the second-level key (column/label).
- The function returns the mapped value found at that intersection.
| Argument position | Description | Example |
|---|---|---|
| 1 (MappingName) | The name of the mapping under the template’s Mappings section | RegionMap |
| 2 (TopLevelKey) | The top-level key (row) to select within the mapping. Can be a literal or an intrinsic (e.g., !Ref) | !Ref “AWS::Region” or “us-east-1” |
| 3 (SecondLevelKey) | The second-level key (column/label) identifying the specific value in the selected row | AMI |
- Use !Ref “AWS::Region” (or other intrinsics) as the TopLevelKey to select region-specific entries.
- Keys and values are literal strings and case-sensitive—ensure the mapping keys match exactly.
- You can nest other intrinsic functions inside the arguments (for example, !Ref, !FindInMap cannot call other mappings but can be used alongside other intrinsics in the same template).
- Fn::FindInMap fails the stack operation if the specified mapping, or keys, do not exist—validate your mappings and test with different regions.
Mappings must be declared under the template’s Mappings section. Fn::FindInMap performs a static lookup at stack create/update — mapping values are part of the template and not dynamically generated outside intrinsic functions.
If a mapping name or key is missing or misspelled, CloudFormation will fail the stack operation. Remember that mapping keys are case-sensitive and must match exactly.
- AWS CloudFormation Fn::FindInMap documentation
- CloudFormation Intrinsic Functions overview
- AWS CloudFormation Mappings section