0
0
Terraformcloud~30 mins

Terraform's declarative approach - Mini Project: Build & Apply

Choose your learning style9 modes available
Terraform's Declarative Approach
📖 Scenario: You are setting up a simple cloud infrastructure using Terraform. You want to create a virtual private cloud (VPC) with a specific CIDR block to isolate your resources.
🎯 Goal: Build a Terraform configuration that declares a VPC resource with a fixed CIDR block using Terraform's declarative syntax.
📋 What You'll Learn
Create a Terraform configuration file named main.tf.
Declare a resource of type aws_vpc named main_vpc.
Set the cidr_block attribute of the VPC to 10.0.0.0/16.
Use Terraform's declarative syntax to define the resource.
💡 Why This Matters
🌍 Real World
Terraform is widely used to manage cloud infrastructure by declaring resources in code, making deployments repeatable and consistent.
💼 Career
Understanding Terraform's declarative syntax is essential for cloud engineers and DevOps professionals to automate infrastructure provisioning.
Progress0 / 4 steps
1
Declare the AWS provider
Write a Terraform block to declare the aws provider with the region set to us-east-1.
Terraform
Need a hint?

The provider block tells Terraform which cloud provider and region to use.

2
Declare the VPC resource
Add a Terraform resource block to declare an aws_vpc resource named main_vpc.
Terraform
Need a hint?

Use the resource keyword followed by the resource type and name.

3
Set the CIDR block for the VPC
Inside the aws_vpc resource named main_vpc, set the cidr_block attribute to 10.0.0.0/16.
Terraform
Need a hint?

The cidr_block defines the IP address range for the VPC.

4
Add a tag to the VPC
Add a tags block inside the aws_vpc resource named main_vpc with a tag Name set to MyVPC.
Terraform
Need a hint?

Tags help identify resources in the cloud console.