0
0
Terraformcloud~30 mins

Terraform CLI overview - Mini Project: Build & Apply

Choose your learning style9 modes available
Terraform CLI Overview
📖 Scenario: You are working as a cloud engineer setting up infrastructure using Terraform. You want to learn how to use the Terraform CLI commands to initialize a project, plan changes, apply infrastructure, and check the state.
🎯 Goal: Build a simple Terraform configuration and use the Terraform CLI commands terraform init, terraform plan, terraform apply, and terraform state list step-by-step to manage infrastructure.
📋 What You'll Learn
Create a Terraform configuration file with a provider and a resource
Initialize the Terraform working directory with terraform init
Generate and review an execution plan with terraform plan
Apply the planned changes with terraform apply
List the resources in the Terraform state with terraform state list
💡 Why This Matters
🌍 Real World
Terraform CLI commands are used daily by cloud engineers to manage infrastructure as code safely and predictably.
💼 Career
Knowing how to use Terraform CLI is essential for roles in cloud infrastructure, DevOps, and site reliability engineering.
Progress0 / 4 steps
1
Create Terraform configuration file
Create a file named main.tf with the following content exactly: a provider block for hashicorp/aws with region us-east-1, and a resource block aws_s3_bucket named my_bucket with bucket name my-terraform-bucket-12345.
Terraform
Need a hint?

Use the provider block to specify AWS and region. Then add a resource block for an S3 bucket with the exact bucket name.

2
Initialize Terraform working directory
Run the Terraform CLI command terraform init in the directory containing main.tf to initialize the working directory and download the AWS provider plugin.
Terraform
Need a hint?

Use your terminal or command prompt to run terraform init in the folder where main.tf is saved.

3
Generate and review execution plan
Run the Terraform CLI command terraform plan to create an execution plan showing the changes Terraform will make to create the S3 bucket resource.
Terraform
Need a hint?

Use your terminal to run terraform plan and review the output showing what Terraform will do.

4
Apply changes and list state resources
Run the Terraform CLI command terraform apply to apply the changes and create the S3 bucket. Then run terraform state list to list the resources managed in the Terraform state.
Terraform
Need a hint?

Use your terminal to run terraform apply and confirm the creation. Then run terraform state list to see the resource names.