0
0
Terraformcloud~30 mins

What is Infrastructure as Code in Terraform - Hands-On Activity

Choose your learning style9 modes available
What is Infrastructure as Code
📖 Scenario: You are working as a cloud engineer. Your team wants to manage cloud resources using code instead of manual clicks. This helps keep track of changes and makes setups repeatable.
🎯 Goal: Build a simple Terraform configuration that creates a cloud resource using code. This shows how Infrastructure as Code works in practice.
📋 What You'll Learn
Create a Terraform configuration file
Define a provider block for AWS
Create a simple AWS resource (like an S3 bucket)
Use variables to configure the resource name
💡 Why This Matters
🌍 Real World
Teams use Infrastructure as Code to automate cloud setups, avoid manual errors, and keep track of changes.
💼 Career
Knowing Infrastructure as Code is essential for cloud engineers, DevOps, and anyone managing cloud infrastructure professionally.
Progress0 / 4 steps
1
Create the Terraform provider block
Write a Terraform configuration that defines the AWS provider with region set to us-east-1. Create a file called main.tf and add the provider block exactly as shown.
Terraform
Need a hint?

The provider block tells Terraform which cloud to work with and where.

2
Add a variable for the bucket name
Add a Terraform variable called bucket_name with a default value of my-terraform-bucket. This variable will hold the name of the S3 bucket.
Terraform
Need a hint?

Variables let you change values without editing the main code.

3
Create an S3 bucket resource using the variable
Add a resource block to create an AWS S3 bucket. Use the variable bucket_name for the bucket's name by referencing var.bucket_name.
Terraform
Need a hint?

Resources define what cloud parts you want to create.

4
Add output to show the bucket name
Add an output block named bucket_id that outputs the bucket's ID using aws_s3_bucket.my_bucket.id. This helps see the result after deployment.
Terraform
Need a hint?

Outputs show important info after Terraform runs.