
Answer-first summary for fast verification
Answer: Use the AWS::Region pseudo parameter
Use the AWS::Region pseudo parameter Pseudo parameters are parameters that are predefined by AWS CloudFormation. You don't declare them in your template. Use them the same way as you would a parameter, as the argument for the Ref function. You can access pseudo parameters in a CloudFormation template like so: Outputs: MyStacksRegion: Value: !Ref "AWS::Region" The AWS::Region pseudo parameter returns a string representing the Region in which the encompassing resource is being created, such as us-west-2. Incorrect options: Create a CloudFormation parameter for Region and let the desired value be populated at the time of deployment - Although it is certainly possible to use a CloudFormation parameter to populate the desired value of the Region at the time of deployment, however, this is not operationally efficient, as you can directly use the AWS::Region pseudo parameter for this. Set up a mapping containing the key and the named values for all AWS Regions and then have the CloudFormation template auto-select the desired value - The Mappings section matches a key to a corresponding set of named values. For example, if you want to set values based on a Region, you can create a mapping that uses the Region name as a key and contains the values you want to specify for each specific Region. You use the Fn::FindInMap intrinsic function to retrieve values in a map. This option is incorrect as the CloudFormation template cannot auto-select the desired value of the Region from a mapping. Create an AWS Lambda-backed custom resource for Region and let the desired value be populated at the time of deployment by the Lambda - Custom resources enable you to write custom provisioning logic in templates that AWS CloudFormation runs anytime you create, update (if you changed the custom resource), or delete stacks. When you associate a Lambda function with a custom resource, the function is invoked whenever the custom resource is created, updated, or deleted. This option is a distractor, as Region is not a custom resource that needs to be provisioned.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
The development team at a company is planning to create an AWS CloudFormation template. Their objective is to automatically populate the AWS Region variable during the deployment process to streamline operations and avoid manual input errors.
What is the MOST operationally efficient method to detect and set the Region in which the CloudFormation template is being deployed?
A
Create an AWS Lambda-backed custom resource for Region and let the desired value be populated at the time of deployment by the Lambda
B
Use the AWS::Region pseudo parameter
C
Create a CloudFormation parameter for Region and let the desired value be populated at the time of deployment
D
Set up a mapping containing the key and the named values for all AWS Regions and then have the CloudFormation template auto-select the desired value
No comments yet.