> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Demo Accessing our mapped values

> 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

```yaml theme={null}
Mappings:
  DevMap:
    Arno:
      Field: Quality assurance
    Alice:
      Field: Backend developer
```

!FindInMap — the three parts

| Argument         | Purpose                                | Example       |
| ---------------- | -------------------------------------- | ------------- |
| Mapping name     | The Mappings block name to search      | DevMap        |
| Top-level key    | The first-level key inside the mapping | Arno or Alice |
| Second-level key | The nested key whose value you want    | Field         |

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.

```yaml theme={null}
Resources:
  MyS3Bucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: !Ref InputBucketName
      Tags:
        - Key: Developer
          Value: !Ref InputDeveloperName
        - Key: Environment
          Value: "Development"
        - Key: Profession
          Value: !FindInMap [DevMap, "Arno", "Field"]

    Metadata:
      Purpose: "Creating an s3 bucket"
      Reviewed: "02-07-2025"
```

Notes on the example

* 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.

<Callout icon="lightbulb" color="#1CB2FE">
  Putting the top-level key in quotes (for example, "Arno") is optional in YAML, but quoting can prevent parsing ambiguity and improve readability.
</Callout>

Full compact template
The compact template below combines Mappings, Parameters, and the S3 resource shown above—use this as a minimal working example.

```yaml theme={null}
Mappings:
  DevMap:
    Arno:
      Field: Quality assurance
    Alice:
      Field: Backend developer

Parameters:
  InputBucketName:
    Type: String
    Description: Please enter your desired S3 bucket name
  InputDeveloperName:
    Type: String
    Description: Please enter the developer name

Resources:
  MyS3Bucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: !Ref InputBucketName
      Tags:
        - Key: Developer
          Value: !Ref InputDeveloperName
        - Key: Environment
          Value: "Development"
        - Key: Profession
          Value: !FindInMap [DevMap, "Arno", "Field"]

Metadata:
  Purpose: "Creating an s3 bucket"
  Reviewed: "02-07-2025"
  Owner: "John Doe"
```

Redeploying the template
To update a stack with this template:

1. In the CloudFormation console choose Update stack → Replace current template → Upload a template file → Choose file.
2. Proceed to the Specify stack details page and fill parameters such as InputBucketName and InputDeveloperName.
3. Complete the update and wait for the stack update to finish.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/7Vg7D5Qe0ykvRK48/images/AWS-CloudFormation/Mappings/Demo-Accessing-our-mapped-values/cloudformation-cf-project-s3-bucket-yaml.jpg?fit=max&auto=format&n=7Vg7D5Qe0ykvRK48&q=85&s=780ee8e7d134a3a5dfb1d0421f5492b3" alt="A screenshot of the AWS CloudFormation console with a Windows file-open dialog overlaid, showing a &#x22;cf-project&#x22; folder and a selected &#x22;s3-bucket&#x22; YAML file. The browser window in the background displays the CloudFormation stack creation UI." width="1920" height="1080" data-path="images/AWS-CloudFormation/Mappings/Demo-Accessing-our-mapped-values/cloudformation-cf-project-s3-bucket-yaml.jpg" />
</Frame>

On the Specify stack details page, set parameters such as InputBucketName and InputDeveloperName (for this demo we selected "Arno" for the developer).

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/7Vg7D5Qe0ykvRK48/images/AWS-CloudFormation/Mappings/Demo-Accessing-our-mapped-values/aws-cloudformation-specify-stack-screenshot.jpg?fit=max&auto=format&n=7Vg7D5Qe0ykvRK48&q=85&s=b6a33caf83f05d62c7c7226f9428eb53" alt="A screenshot of the AWS CloudFormation &#x22;Specify stack details&#x22; page for updating a stack, showing parameters including InputBucketName set to &#x22;eden-kodekloud-bncv-bkt&#x22; and InputDeveloperName set to &#x22;Arno.&#x22; The left sidebar shows the multi-step progress with &#x22;Specify stack details&#x22; highlighted and navigation buttons (Previous, Next) appear at the bottom." width="1920" height="1080" data-path="images/AWS-CloudFormation/Mappings/Demo-Accessing-our-mapped-values/aws-cloudformation-specify-stack-screenshot.jpg" />
</Frame>

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).

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/7Vg7D5Qe0ykvRK48/images/AWS-CloudFormation/Mappings/Demo-Accessing-our-mapped-values/aws-s3-bucket-tags-profession-highlight.jpg?fit=max&auto=format&n=7Vg7D5Qe0ykvRK48&q=85&s=2cb2e6596def854fc0207949ac84cf5c" alt="A screenshot of the AWS S3 console showing the properties/tags for a bucket (keys like Status: Active, aws:cloudformation:stack-name: DemoStack, Developer: Arno, Environment: Development). The &#x22;Profession&#x22; tag (&#x22;Quality assurance&#x22;) is highlighted." width="1920" height="1080" data-path="images/AWS-CloudFormation/Mappings/Demo-Accessing-our-mapped-values/aws-s3-bucket-tags-profession-highlight.jpg" />
</Frame>

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.

Links and references

* [CloudFormation Overview](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html)
* [Intrinsic function: !FindInMap](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-findinmap.html)
* [Mappings section structure](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/mappings-section-structure.html)
* [Update a stack (CloudFormation)](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks.html)
* [Amazon S3 Documentation](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/aws-cloud-formation/module/4e0caf18-41ee-4499-8c83-b0dc280c537a/lesson/33a30cb1-053c-4ff8-85af-dc29611dd90b" />
</CardGroup>
