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.

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

git clone..tf files and ran the workflow: init → validate → plan → apply. index.html, CSS and JavaScript — no web server needed. random_id.suffix — an 8-character hex suffix, because S3 bucket names must be globally uniqueaws_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 workaws_s3_bucket_website_configuration.site — enables website hosting with error.html aws_s3_bucket_policy.public_read — allows public s3:GetObject so visitors can read the siteaws_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"

terraform.tfstate lets terraform destroy removes everything Terraform created, and stopping the EC2 instance keeps costs low. 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

原文来源:dev.to