Project: Find the CIDR Range

Test your knowledge by implementing two parts of a Terraform project

Problem statement#

There will be two parts of this project. Let’s first look into their problem statements.

Part one#

Make a Terraform project that creates a VPC and sets the tag Name to your name.

Part two#

Create another Terraform project that looks up that VPC using a data block filtering on the Nametag and outputs the CIDR range of the VPC to the terminal.

Output#

Subfolder part1 creates the VPC with the Name tag set to Kevin. Subfolder part2 shows how to look this up by data block and output it.

Now, let’s see what should be the output for both of the folders.

part1#

The following should be the output after running terraform apply in the part1 folder:

aws_vpc.vpc: Creating...
aws_vpc.vpc: Creation complete after 7[id=vpc-08c1764b885f93805]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

part2#

After running terraform apply in the part2 folder, the CIDR range should be printed on the screen.

Folder structure#

Let’s look into the folder structure of this project:

part1#

Implement the solution of part 1 of the problem in this folder.

Terraform project part1 files used to implement the project

part 2#

Implement the solution of part 2 of the problem in this folder.

Terraform project part2 files used to implement the project

Running the project#

You can use the following commands to run the project:

📝Note: Please use the cd command to move to the specific folder and run the commands.

part1#

Inside the part1 folder, run commands:

terraform init
terraform apply

part2#

Inside the part2 folder, run commands:

terraform init
terraform apply

📝Note: Clicking the RUN button will move you to the part1 folder and run terraform init commands.

Coding exercise#

Try to solve the above problem. If you can’t solve it, don’t give up. In the next lesson, we will discuss the solution in detail.

Good Luck!

This code requires the following environment variables to execute:
access_key_id
Not Specified...
secret_access_key
Not Specified...
/
part1
part2
terraform.tfstate
main.tf
Solution Review: Create a VPC with a CIDR Range
Solution Review: Find the CIDR Range
Mark as Completed
Report an Issue