This project demonstrates how to host a static website on Amazon S3 using Terraform.
This project provides Terraform configurations to deploy a static website to Amazon S3. It sets up the S3 bucket, configures it for website hosting, and uploads the website files.
Before you begin, ensure you have the following prerequisites:
- Terraform installed on your local machine.
- An AWS account with appropriate permissions to create resources such as S3 buckets.
- AWS CLI configured with access key and secret key.
To install and deploy the project, follow these steps:
-
Clone the repository to your local machine:
git clone https://github.com/adil6572/terraform-s3-hosting.git
-
Change into the project directory:
cd terraform_s3_hosting
-
Initialize Terraform:
terraform init
The project uses the following variables defined in variables.tf
:
bucket_name
: The name of the S3 bucket to host the website.
The project directory structure is as follows:
terraform_s3_hosting/
├── output.tf
├── provider.tf
├── s3.tf
├── s3.tfvars
└── variables.tf
├── Web
Change the website files in web
folder you want to host:
To deploy the static website to Amazon S3, follow these steps:
-
Configure your AWS credentials using AWS CLI if you haven't already:
aws configure
-
Review and adjust the
s3.tfvars
file with your desired configurations. -
Apply the Terraform configuration to create the infrastructure:
terraform apply -var-file=s3.tfvars
This project is licensed under the MIT License.
- Special thanks to the Terraform community for their excellent documentation and resources.