Terraform Automation — EC2 & S3

A lightweight, serverless Infrastructure-as-Code setup powered by GitHub Actions and Terraform — using a single S3 backend. Simple, elegant, and entirely cloud-native.

Overview

This project automates AWS infrastructure provisioning using Terraform with a unified S3 backend. It supports EC2 instance creation, S3 bucket provisioning, secure key management, and email notifications — all orchestrated via GitHub Actions.

⚙️ GitHub Actions Workflow Inputs

The workflow supports dynamic inputs to customize each run:

These inputs make the workflow reusable for multiple environments and purposes — from sandbox deployments to automated teardown.

Our Choice: S3 Backend
• Zero extra AWS components to maintain.
• Ideal for small teams and personal DevOps setups.
• Fully serverless and portable — one bucket, multiple modules.
• Less cost, fewer permissions, and faster initialization.

This approach keeps the infrastructure minimal and universally deployable — Terraform as code, not as overhead.

Setup Steps

  1. Initialize backend: cd backend && terraform init && terraform apply -auto-approve
  2. Commit & push to GitHub — Actions auto-triggers with inputs.
  3. Review outputs — Terraform JSON results and EC2 details are emailed post-run.
  4. Artifacts — generated tf-key.pem securely stored as workflow artifact.

Example Terraform Outputs:

{
  "instance_id": "i-0abc12345def67890",
  "public_ip": "13.233.115.21",
  "bucket_name": "terraform-ci-demo-bucket"
}

Terraform Snippet

Each module begins with this minimal backend block:

terraform {
  backend "s3" {}
  required_providers {
    aws = { source = "hashicorp/aws" }
  }
}

GitHub Actions injects backend parameters like bucket, key, and region automatically during each run.