0
0
Terraformcloud~30 mins

Why resources are Terraform's core - See It in Action

Choose your learning style9 modes available
Why resources are Terraform's core
📖 Scenario: Imagine you want to create a simple cloud setup with a virtual server. Terraform helps you do this by defining resources, which are like building blocks for your cloud environment.
🎯 Goal: You will create a Terraform configuration that defines a single cloud resource, then add a variable to configure it, apply the main logic to set its properties, and finally complete the configuration to make it deployable.
📋 What You'll Learn
Create a Terraform resource block for an AWS EC2 instance
Add a variable to set the instance type
Use the variable inside the resource configuration
Complete the resource with a required tag
💡 Why This Matters
🌍 Real World
Cloud engineers use Terraform resources to define and manage servers, databases, and networks in a repeatable way.
💼 Career
Understanding resources is essential for roles like Cloud Engineer, DevOps Engineer, and Infrastructure Developer who automate cloud setups.
Progress0 / 4 steps
1
Create the initial resource block
Write a Terraform resource block named aws_instance with the resource name example. Set the ami attribute to the exact value "ami-12345678".
Terraform
Need a hint?

The resource block starts with resource "aws_instance" "example" { and ends with }. Inside, set ami = "ami-12345678".

2
Add a variable for instance type
Create a Terraform variable named instance_type with the default value "t2.micro".
Terraform
Need a hint?

Use variable "instance_type" { default = "t2.micro" } to define the variable.

3
Use the variable inside the resource
Inside the aws_instance.example resource block, add the attribute instance_type and set it to use the variable instance_type with var.instance_type.
Terraform
Need a hint?

Inside the resource block, add instance_type = var.instance_type to connect the variable.

4
Add a tag to complete the resource
Inside the aws_instance.example resource block, add a tags block with a single tag Name set to "ExampleInstance".
Terraform
Need a hint?

Add a tags block with Name = "ExampleInstance" inside the resource.