Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Basics

Companion lab for the Medium article Creating Your First Instance with Terraform. Part of my Terraform fundamentals series — more on Medium.


What you'll learn

How to provision your first AWS EC2 instance with Terraform from scratch — understanding providers, input variables, local state, and the planapplydestroy resource lifecycle.

Architecture

┌──────────────────┐       ┌──────────────────────┐
│   Terraform      │       │   AWS                │
│   (local state)  │ ────► │   EC2 t3.small       │
│                  │       │   region: us-east-1  │
└──────────────────┘       └──────────────────────┘

What's inside

File Purpose
provider.tf Declares the AWS provider (v5.31.0) and region
variables.tf Defines region and vm_name input variables
main.tf Creates the EC2 instance resource with tags
backend.tf Configures local state backend

Prerequisites

  • Terraform ≥ 1.5
  • AWS CLI configured (aws configure) with a default profile
  • An AWS account (free tier covers this lab)

Quick start

# Initialize providers and backend
terraform init

# Preview what will be created
terraform plan

# Provision the instance
terraform apply

After apply, a t3.small EC2 instance named vm01 will exist in us-east-1, tagged with Terraform = true.

Cleanup

terraform destroy

Always destroy lab resources — EC2 instances accrue hourly charges.

Key concepts

  • Providers — how Terraform talks to cloud APIs (hashicorp/aws)
  • Input variables — parameterize your infrastructure (var.region, var.vm_name)
  • State — Terraform's source of truth for what exists (local backend here)
  • Resource lifecycleplan previews, apply creates, destroy removes

Series

Part of my Terraform fundamentals series:

All articles on Medium.

About

Hands-on Terraform starter lab — provisioning AWS resources. Companion to a Medium article.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages