Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
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
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
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
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
Hint
Outputs show important info after Terraform runs.
Practice
(1/5)
1. What does Infrastructure as Code mean in simple terms?
easy
A. Using physical servers instead of cloud
B. Manually clicking buttons in the cloud console
C. Writing text files to create and manage cloud resources
D. Writing code only for applications, not infrastructure
Solution
Step 1: Understand the concept of Infrastructure as Code
It means using code or text files to define and manage infrastructure instead of manual steps.
Step 2: Compare options with this definition
Only Writing text files to create and manage cloud resources describes writing text files to manage cloud resources, matching the concept.
Final Answer:
Writing text files to create and manage cloud resources -> Option C
Quick Check:
Infrastructure as Code = writing text files [OK]
Hint: Think: code controls infrastructure, not manual clicks [OK]
Common Mistakes:
Confusing manual setup with code-based setup
Thinking Infrastructure as Code means only coding apps
Assuming physical servers are Infrastructure as Code
2. Which of these is a correct Terraform resource block syntax?
easy
A. resource "aws_instance" "web" { ami = "ami-123" instance_type = "t2.micro" }
B. resource aws_instance web { ami = ami-123 instance_type = t2.micro }
C. resource "aws_instance" web { ami = "ami-123" instance_type = "t2.micro" }
D. resource "aws_instance" "web" ( ami = "ami-123", instance_type = "t2.micro" )
Solution
Step 1: Recall Terraform resource block syntax
It requires the keyword resource, resource type and name in quotes, then braces with key-value pairs.
Step 2: Check each option for correct syntax
resource "aws_instance" "web" { ami = "ami-123" instance_type = "t2.micro" } uses quotes for type and name, braces, and key-value pairs with equals and quotes correctly.
Final Answer:
resource "aws_instance" "web" { ami = "ami-123" instance_type = "t2.micro" } -> Option A