By Divyapriya S — Software Developer | Cloud Engineer

One command to build a website on AWS, and one command to remove it. That idea — Infrastructure as Code — is at the heart of my latest project.

What I built

I built the Tamil Nadu Tour Guide, a static website that helps visitors explore places in Tamil Nadu by type, plan a quick trip, discover local food, and open an AI guide built with PartyRock. Instead of clicking through the AWS console, I managed everything with Terraform.

Live website: http://tamilnadu-tour-guide-6e9ce982.s3-website.ap-south-1.amazonaws.com/#places
Source code: https://github.com/DivyaPriya250413/tn-tour-guide-terraform

Tools and services

  • Amazon S3 — static website hosting
  • Amazon EC2 (Amazon Linux) — the server where I ran Terraform and the AWS CLI
  • Terraform 1.5+ with AWS provider 5.x and the random provider
  • AWS CLI v2
  • Git and GitHub — source of truth for the code
  • Region: ap-south-1 (Mumbai)

How it works

  1. The Terraform project and website files were created as a project zip and pushed to GitHub.
  2. On the EC2 instance, I cloned the repository with git clone.
  3. Terraform read the .tf files and ran the workflow: init → validate → plan → apply.
  4. Terraform called the AWS API and created the S3 bucket, its website configuration, public access settings and bucket policy, and uploaded the website files.
  5. A visitor opens the S3 website endpoint and gets index.html, CSS and JavaScript — no web server needed.

What Terraform creates

  • random_id.suffix — an 8-character hex suffix, because S3 bucket names must be globally unique
  • aws_s3_bucket.site — the bucket tamilnadu-tour-guide-6e9ce982
  • aws_s3_bucket_public_access_block.site — relaxes Block Public Access for this bucket so the public policy can work
  • aws_s3_bucket_website_configuration.site — enables website hosting with index.html and error.html
  • aws_s3_bucket_policy.public_read — allows public s3:GetObject so visitors can read the site
  • aws_s3_object.site_files — uploads each file in website/ with the correct content type, re-uploading only changed files

The result of terraform apply: Apply complete! Resources: 9 added, 0 changed, 0 destroyed. bucket_name = "tamilnadu-tour-guide-6e9ce982", website_url = "http://tamilnadu-tour-guide-6e9ce982.s3-website.ap-south-1.amazonaws.com"

What I learned

  • Infrastructure as Code makes work repeatable. The same files create the same infrastructure every time, and terraform.tfstate lets plan show only the differences.
  • Always run plan before apply. It takes seconds and prevents surprises in your AWS account.
  • Keep secrets out of Git. Never commit access keys or state files — and an IAM role on EC2 is safer than long-lived keys stored on the server.
  • Clean up. terraform destroy removes everything Terraform created, and stopping the EC2 instance keeps costs low.
  • S3 website endpoints are HTTP only. For HTTPS, the next step is Amazon CloudFront with a certificate in front of the bucket.

Try it live

Visit the Tamil Nadu Tour Guide here: http://tamilnadu-tour-guide-6e9ce982.s3-website.ap-south-1.amazonaws.com/#places
The full step-by-step guide, with every command explained, is in my PDF guide: Hosting a Static Website on AWS with Terraform — The Tamil Nadu Tour Guide site, built with Amazon S3, EC2 and GitHub

Let's connect