Shows how to use CloudFormation Mappings and !FindInMap to retrieve values and apply them to resource tags using an S3 bucket example with deployment and verification steps
In this lesson we’ll learn how to retrieve values from a CloudFormation Mappings block using the !FindInMap intrinsic function. Mappings are useful for storing static lookup data (for example, environment-specific settings or role-to-profession mappings) and then referencing those values elsewhere in your template.Mappings example
Using the mapping in a resource tag
Below is a simplified Resources snippet that adds tags to an S3 bucket. The Profession tag pulls its value from the mapping using !FindInMap.
The !FindInMap invocation returns the value at Mappings → DevMap → Arno → Field, which is “Quality assurance”.
The Developer tag is populated from the InputDeveloperName parameter so the developer name appears in the S3 console; Profession is taken from the mapping instead of being hard-coded in the Tags list.
You can make the top-level key dynamic (for example, by referencing a parameter instead of hard-coding “Arno”) to select different mapped values at stack creation or update time.
Putting the top-level key in quotes (for example, “Arno”) is optional in YAML, but quoting can prevent parsing ambiguity and improve readability.
Full compact template
The compact template below combines Mappings, Parameters, and the S3 resource shown above—use this as a minimal working example.
Redeploying the template
To update a stack with this template:
In the CloudFormation console choose Update stack → Replace current template → Upload a template file → Choose file.
Proceed to the Specify stack details page and fill parameters such as InputBucketName and InputDeveloperName.
Complete the update and wait for the stack update to finish.
On the Specify stack details page, set parameters such as InputBucketName and InputDeveloperName (for this demo we selected “Arno” for the developer).
Verifying the mapped value
After the stack update completes, open the S3 bucket in the S3 console and navigate to Properties → Tags to confirm the mapping was applied. In this example:
Developer tag shows the parameter value “Arno”.
Profession tag shows “Quality assurance” (the value resolved from DevMap → Arno → Field).
Summary
!FindInMap requires three arguments: mapping name, top-level key, and second-level key.
Use Mappings to centralize static lookup data and avoid duplication across your template.
Combine Parameters and Mappings to let users control keys (top-level lookup) while still resolving other values from a central mapping.