As an AWS system administrator, you need to maintain CloudFormation templates used to deploy an application in multiple AWS Regions.
At the moment, each AWS region has its own CloudFormation template as the AMI ID is different per region.
You want to parameterize the AMI ID so that the same CloudFormation template can be reused for different AWS Regions.
Which of the following options is the most suitable?
Click on the arrows to vote for the correct answer
A. B. C. D.Correct Answer: D.
Option A is incorrect because there is no “Fn::FindInParameter” intrinsic function.
It is not how parameters are used in CloudFormation.
To reference a parameter, you need to use the “Ref” intrinsic function.
Option B is incorrect because “Conditions” are used to define different circumstances.
The “Conditions” section is not suitable to define AMI IDs.
Option C is incorrect because the optional “Metadata” section provides details about the template such as descriptions.
It cannot define AMI IDs.
Option D is CORRECT because the “Mappings” section is suitable to create a mapping with key/value pairs.
In this case, the key is the AWS region, and the value is the AMI ID.
The values in the map can be retrieved through the “Fn::FindInMap” function.
Reference:
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/mappings-section-structure.htmlCloudFormation templates are used to deploy and manage AWS resources in an automated and consistent manner. In this scenario, the AWS system administrator wants to maintain a single CloudFormation template that can be used to deploy the application across multiple AWS regions, but with different AMI IDs for each region.
Option A: Use the “Parameters” section to define the AMI ID per region and return the correct AMI ID through the “Fn::FindInParameter” intrinsic function.
The “Parameters” section is used to define input parameters that are passed to the CloudFormation template at deployment time. The AMI ID can be defined as a parameter and assigned different values for each region. The “Fn::FindInParameter” intrinsic function can be used to return the correct AMI ID based on the region parameter passed in during deployment.
Option B: Use “Conditions” to include different AMI IDs per region and return the correct AMI ID through the “Fn::If” intrinsic function.
The “Conditions” section is used to define conditions that determine whether certain resources should be created or not. The AMI ID can be included as a condition and assigned different values for each region. The “Fn::If” intrinsic function can be used to return the correct AMI ID based on the region condition.
Option C: Use “Metadata” to define different AMI IDs per region and return the correct AMI ID through the “Fn::FindInMetadata” intrinsic function.
The “Metadata” section is used to provide additional data about the CloudFormation template, such as version, description, and dependencies. The AMI ID can be defined in the metadata and assigned different values for each region. The “Fn::FindInMetadata” intrinsic function can be used to return the correct AMI ID based on the region metadata.
Option D: Use “Mappings” to include different AMI IDs per region and return the correct AMI ID through the “Fn::FindInMap” intrinsic function.
The “Mappings” section is used to define a set of named values that can be used in the CloudFormation template. The AMI ID can be included as a mapping and assigned different values for each region. The “Fn::FindInMap” intrinsic function can be used to return the correct AMI ID based on the region mapping.
Based on the options provided, the most suitable approach for parameterizing the AMI ID and maintaining a single CloudFormation template that can be used across multiple AWS regions is Option A. The “Parameters” section is designed to accept input parameters, and the “Fn::FindInParameter” intrinsic function is used to return the correct AMI ID based on the region parameter passed in during deployment.