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
Why IaC over manual provisioning
📖 Scenario: You work as a cloud engineer for a small company. The company wants to set up a simple web server on a cloud provider. They are deciding between creating the server manually through the cloud console or using code to automate the setup.
🎯 Goal: Build a simple Terraform configuration that creates a virtual machine instance. This will show how Infrastructure as Code (IaC) works compared to manual setup.
📋 What You'll Learn
Create a Terraform configuration file named main.tf
Define a resource for a virtual machine instance with specific properties
Add a variable to configure the instance type
Use the variable in the resource configuration
Add an output to show the instance's public IP address
💡 Why This Matters
🌍 Real World
Cloud engineers use Infrastructure as Code to automate and manage cloud resources reliably and quickly.
💼 Career
Knowing IaC tools like Terraform is essential for roles in cloud operations, DevOps, and infrastructure management.
Progress0 / 4 steps
1
Create the initial Terraform resource
Create a Terraform resource named aws_instance called web_server with the following properties: ami = "ami-0c55b159cbfafe1f0" and instance_type = "t2.micro" inside a file named main.tf.
Terraform
Hint
The resource block starts with resource "aws_instance" "web_server" { and ends with }.
2
Add a variable for instance type
Add a Terraform variable named instance_type with a default value of "t2.micro" in the same main.tf file.
Terraform
Hint
Use variable "instance_type" {} block and refer to it as var.instance_type inside the resource.
3
Add an output for the public IP
Add an output named public_ip that shows the public_ip attribute of the aws_instance.web_server resource in main.tf.
Terraform
Hint
Use output "public_ip" { value = aws_instance.web_server.public_ip } to show the IP.
4
Explain why IaC is better than manual provisioning
Add a comment at the top of main.tf explaining in simple words why using Terraform (IaC) is better than creating the server manually.
Terraform
Hint
Write a simple comment starting with # explaining benefits like repeatability, fewer errors, and tracking.
Practice
(1/5)
1. Why is Infrastructure as Code (IaC) preferred over manual cloud provisioning?
easy
A. Manual provisioning tracks changes automatically.
B. Manual provisioning is faster for large-scale deployments.
C. IaC requires no knowledge of cloud services.
D. IaC automates setup, saving time and reducing human errors.
Solution
Step 1: Understand automation benefits of IaC
IaC automates cloud setup, which reduces manual work and human mistakes.
Step 2: Compare manual provisioning drawbacks
Manual provisioning is slower and prone to errors, especially at scale.
Final Answer:
IaC automates setup, saving time and reducing human errors. -> Option D
Quick Check:
Automation = IaC advantage [OK]
Hint: IaC automates and reduces errors, unlike manual steps [OK]
Common Mistakes:
Thinking manual is faster for big setups
Believing IaC needs no cloud knowledge
Assuming manual tracks changes automatically
2. Which Terraform command applies your infrastructure code to create resources?
easy
A. terraform apply
B. terraform plan
C. terraform init
D. terraform destroy
Solution
Step 1: Identify command to create resources
terraform apply runs the code and creates or updates infrastructure.
Step 2: Differentiate from other commands
terraform plan shows changes, init sets up, destroy deletes resources.
Final Answer:
terraform apply -> Option A
Quick Check:
Apply = create/update resources [OK]
Hint: Apply means execute changes to infrastructure [OK]
Common Mistakes:
Confusing plan with apply
Using init to create resources
Destroying instead of applying
3. Given this Terraform snippet, what is the main benefit of using it instead of manual setup?