DVA-C02 · Question #478
A developer is using AWS CloudFormation to deploy an AWS Lambda function. The developer needs to set the Lambda function's timeout value based on the environment parameter of the template. The templat
The correct answer is B. Timeout: !FindInMap [EnvironmentData, !Ref Environment, Timeout]. !FindInMap is the correct CloudFormation intrinsic function for looking up values in a Mappings section - it takes exactly three arguments: the map name, a top-level key, and a second-level key, making [EnvironmentData, !Ref Environment, Timeout] the precise syntax for this use c
Question
A developer is using AWS CloudFormation to deploy an AWS Lambda function. The developer needs to set the Lambda function's timeout value based on the environment parameter of the template. The template contains mappings of EnvironmentData for each environment's timeout value. The environment parameter and EnvironmentData mappings are as follows:
Environment parameter:
EnvironmentData mappings:
Which statement will meet these requirements?
Options
- ATimeout: !GetAtt [EnvironmentData, !Ref Environment, Timeout]
- BTimeout: !FindInMap [EnvironmentData, !Ref Environment, Timeout]
- CTimeout: !Select [EnvironmentData, !Ref Environment, Timeout]
- DTimeout: !ForEach[EnvironmentData, !Ref Environment, Timeout]
How the community answered
(17 responses)- B82% (14)
- C6% (1)
- D12% (2)
Explanation
!FindInMap is the correct CloudFormation intrinsic function for looking up values in a Mappings section - it takes exactly three arguments: the map name, a top-level key, and a second-level key, making [EnvironmentData, !Ref Environment, Timeout] the precise syntax for this use case.
Why the distractors fail:
- A (
!GetAtt) retrieves attributes from resources (e.g., an S3 bucket ARN), not mapping values - it doesn't accept a map name as input. - C (
!Select) picks an item from a list by index number, not by named key, so it can't navigate a named mapping structure. - D (
!ForEach) is used in CloudFormation transform loops to iterate over a collection - it's not a lookup function and doesn't exist in this context.
Memory tip: Think "Find it on the Map" - !FindInMap is always your go-to when the template has a Mappings block and you need to retrieve a value using keys. The three-part structure [MapName, TopKey, SecondKey] mirrors drilling down two levels into the map.
Topics
Community Discussion
No community discussion yet for this question.