This project provisions an AWS S3 bucket to host a static website using Terraform. It configures the necessary policies to allow public access to the website files and uploads all content from the website directory.
- Terraform: Infrastructure as Code (IaC) tool used to provision AWS resources.
- AWS S3: Object storage service used to host the static website.
- S3 Bucket Policy: Grants public read access to objects within the bucket.
- S3 Website Configuration: Enables static website hosting with an index document.
Ensure you have the following installed before proceeding:
git clone <repository_url>
cd <repository_name>Ensure your AWS credentials are set up properly using the AWS CLI:
aws configureAlternatively, you can use an IAM role if running from an AWS environment.
Run the following command to initialize Terraform and download required providers:
terraform initModify the variables.tf file to set the AWS region and S3 bucket name:
variable "aws_region" {
default = "us-east-1"
}
variable "aws_bucket_name" {
default = "your-unique-bucket-name"
}Run the following command to create the resources:
terraform apply -auto-approveThis will provision the S3 bucket, configure policies, and upload website files.
After deployment, Terraform outputs the website URL. You can retrieve it using:
echo $(terraform output website_url)Copy and paste the URL into a browser to view your static website.
To destroy the resources and remove the S3 bucket, run:
terraform destroy -auto-approveThis will delete all provisioned resources.
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to open issues or submit pull requests to improve this project.