0
0
Terraformcloud~30 mins

Why HCL matters as Terraform's language - See It in Action

Choose your learning style9 modes available
Why HCL matters as Terraform's language
📖 Scenario: You are learning Terraform, a tool that helps you create and manage cloud resources easily. Terraform uses a special language called HCL (HashiCorp Configuration Language) to describe what you want in the cloud. Understanding why HCL is used helps you write better Terraform code.
🎯 Goal: Build a simple Terraform configuration using HCL to create a cloud resource, and see how HCL's design makes it easy to read and manage.
📋 What You'll Learn
Create a Terraform configuration file using HCL syntax
Define a provider block for AWS
Create a simple AWS S3 bucket resource
Use variables to configure the bucket name
💡 Why This Matters
🌍 Real World
Cloud engineers use Terraform with HCL to automate creating and managing cloud resources like servers, storage, and networks.
💼 Career
Understanding HCL is essential for roles in cloud infrastructure, DevOps, and site reliability engineering where Terraform is a key tool.
Progress0 / 4 steps
1
Create the provider block
Write a Terraform configuration with a provider block for AWS. Use region = "us-east-1" inside the block.
Terraform
Need a hint?

The provider block tells Terraform which cloud to work with. Use provider "aws" {} and set the region inside.

2
Add a variable for the bucket name
Add a variable block named bucket_name with a default value of "my-terraform-bucket".
Terraform
Need a hint?

Variables let you reuse values. Use variable "bucket_name" { default = "my-terraform-bucket" }.

3
Create an S3 bucket resource using the variable
Add a resource block named aws_s3_bucket with the name my_bucket. Set its bucket attribute to use the variable bucket_name with var.bucket_name.
Terraform
Need a hint?

Resources define cloud objects. Use resource "aws_s3_bucket" "my_bucket" { bucket = var.bucket_name }.

4
Add a tag to the S3 bucket
Inside the aws_s3_bucket resource block, add a tags block with a tag Environment set to "Dev".
Terraform
Need a hint?

Tags help organize resources. Add tags = { Environment = "Dev" } inside the resource.