From ClickOps to DevOps: My First Infrastructure as Code Project with Terraform

Published: (December 27, 2025 at 07:37 AM EST)
1 min read
Source: Dev.to

Source: Dev.to

Introduction

The Architecture

  • VPC: A custom Virtual Private Cloud.
  • Subnet: A public subnet for the instance.
  • Internet Gateway (IGW): To allow internet access.
  • Route Table: Configuring routes to the IGW.
  • Security Group: Allowing SSH, HTTP, and HTTPS.
  • EC2 Instance: The server itself.

Why Terraform?

The Code

The Network Setup

resource "aws_internet_gateway" "terra-igw" {
  # configuration omitted for brevity
}

resource "aws_subnet" "terra-subnet1" {
  # configuration omitted for brevity
}

Security Groups

  • Allow SSH from anywhere.
  • Allow all outbound traffic.

The Instance

resource "aws_instance" "my_server" {
  # other configuration omitted

  tags = {
    # tag definitions
  }
}

The Workflow: 4 Magic Commands

  • terraform init – Initializes the directory and downloads the necessary AWS providers.
  • terraform validate – Checks your code for syntax errors before you run it.
  • terraform plan – Shows a “dry run” of what will be created, changed, or destroyed, giving you confidence before applying changes.
  • terraform apply – Executes the API calls to AWS to build the resources.

Conclusion

Have you worked with Terraform? What was the first resource you automated? Let me know in the comments! 👇

Back to Blog

Related posts

Read more »

AWS VPC

What is AWS VPC? An AWS Virtual Private Cloud VPC is a logically isolated network inside AWS where you can launch resources such as: - EC2 instances - Database...