- In this project, I developed a streamlined infrastructure for hosting a static website using Terraform and Amazon Web Services (AWS) S3. The primary goal of this project is to demonstrate the automated provisioning and deployment of a web hosting solution for static websites.
I utilized Terraform, an IaC tool, to define and provision the AWS resources required for my static website hosting solution. This allows for version-controlled, repeatable infrastructure deployments.
I created an S3 bucket to store and serve the static website files. This bucket is configured for website hosting, allowing for easy content delivery.
I provided instructions and scripts for uploading and managing my website content within the S3 bucket.
Step 1: Set Up Your Development Environment
aws configure
Step 2: Define Your Website Content
index.html
error.html
Step 3: Terraform Configuration File Syntax
-
Create terraform files for s3 bucket create and upload the website source code.
resource.tf
provider.tf
Step 4: Define output variable for s3 endpoint url to access website.
output "websiteendpoint" {
value = aws_s3_bucket.bucket1.website_endpoint
}
Step 5:Terraform to provisioning the resources
terraform init
terraform plan
terraform apply -auto-approve
Step 6: Verify the Output
-
aws_s3_bucket.bucket1 has changed
web-bucket-pro1.s3-website.ap-south-1.amazonaws.com
Step 7: Destroy the all resources
terraform destroy --auto-approve