Automating VPC Creation with CloudFormation Template

Replicating VPC Creation Template Across Regions

Prev Question Next Question

Question

As an AWS consultant, you have been assigned to automate the VPC creation process.

You successfully performed POC at the ap-northeast-1 region using AWS CloudFormation Template.

With this template, you have created a VPC with public & private subnets with CIDR range along with an Internet Gateway.

You need to replicate the same template in other regions for deployment.

Which of the following can be used to incorporate the CIDR range of the region to the template so that users in each region can select these values?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answer - B.

Template Parameters can be used to customize Resource Properties in a template so that these templates can be re-used in deployment in other regions.

In the above case, with Template Parameters, users can specify the CIDR range of a specific region while creating a stack.

Option A is incorrect as Reference will return physical ID for the resources.

This will be used to refer to parameter values in a template.

Option C is incorrect as Fn::Cidr can be used to create smaller CIR blocks for a specified count& size from a larger CIDR block.

This cannot be used to specify the CDR range during Stack creation.

Option D is incorrect as Fn::Select can be used to select one value from a range of values in a function.

This cannot be used to specify the CDR range during Stack creation.

For more information on using AWS CloudFormation Templates for VPC creation, refer to the following URL.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html

The correct answer is B. Use Parameters in AWS CloudFormation to allow users in different regions to specify region-specific CIDR ranges during Stack creation.

AWS CloudFormation is a service that allows you to model and provision AWS infrastructure resources as code. With CloudFormation, you can define your infrastructure as code using a template, which is a JSON or YAML-formatted text file. CloudFormation provisions and configures resources in a safe, repeatable, and predictable manner.

To automate the VPC creation process, you can use a CloudFormation template that describes the VPC's configuration, including its CIDR block, subnets, and associated resources. However, the CIDR block of the VPC may differ from one region to another. Therefore, you need to allow users in each region to specify region-specific CIDR ranges during stack creation.

The correct approach to accomplish this is to use parameters in the CloudFormation template. Parameters are inputs that you can define in your CloudFormation template to accept values at runtime. In this case, you can define a parameter for the CIDR block of the VPC, and users can enter the CIDR block value during stack creation. This approach enables users to specify region-specific CIDR ranges during stack creation.

Option A, creating a reference in the CloudFormation template, is not a valid approach because you cannot reference region-specific values in the template directly. Option C, using the Fn::Cidr function, is also not valid because it returns a CIDR range for a given IP address and prefix. It is not suitable for this scenario where you need to allow users to specify the CIDR block for the VPC. Option D, using the Fn::Select function, is also not valid because it returns a specified element from a list. It is not suitable for this scenario where you need to allow users to specify the CIDR block for the VPC.