0
0
Terraformcloud~30 mins

Terraform state list command - Mini Project: Build & Apply

Choose your learning style9 modes available
Terraform state list command
📖 Scenario: You are managing cloud infrastructure using Terraform. You want to see which resources Terraform currently manages in your project.
🎯 Goal: Learn how to use the terraform state list command to view all resources tracked in the Terraform state file.
📋 What You'll Learn
Create a Terraform configuration with at least two resources
Initialize Terraform in the project directory
Apply the Terraform configuration to create resources
Use the terraform state list command to list all managed resources
💡 Why This Matters
🌍 Real World
Terraform state files keep track of all resources created by Terraform. Knowing how to list these resources helps you understand what Terraform manages and troubleshoot your infrastructure.
💼 Career
Cloud engineers and DevOps professionals use Terraform daily to manage infrastructure. Being able to inspect the Terraform state is essential for safe and effective infrastructure management.
Progress0 / 4 steps
1
Create a Terraform configuration with two resources
Create a file named main.tf with two resources: an AWS S3 bucket named my_bucket and an AWS DynamoDB table named my_table. Use the exact resource names aws_s3_bucket.my_bucket and aws_dynamodb_table.my_table.
Terraform
Need a hint?

Define two resources with the exact names my_bucket and my_table inside main.tf.

2
Initialize Terraform in the project directory
Run the command terraform init in your project directory to initialize Terraform and download the AWS provider.
Terraform
Need a hint?

Use your terminal to run terraform init to prepare Terraform.

3
Apply the Terraform configuration to create resources
Run the command terraform apply -auto-approve to create the resources defined in main.tf and update the Terraform state file.
Terraform
Need a hint?

Use your terminal to run terraform apply -auto-approve to create resources without manual confirmation.

4
List all resources tracked in the Terraform state
Run the command terraform state list in your project directory to see all resources Terraform currently manages in the state file.
Terraform
Need a hint?

Use your terminal to run terraform state list to see all resources Terraform manages.