This Terraform configuration creates a simple static website hosted on an AWS S3 Bucket.
- Terraform installed on your machine
- AWS credentials configured locally
-
Clone the repository and navigate to the directory containing the Terraform files.
-
Initialize the Terraform configuration:
terraform init
-
Apply the Terraform configuration to create the static website:
terraform apply
-
After the apply is successful, the static website will be accessible at the provided S3 bucket website endpoint.
-
To clean up and delete the resources created by Terraform, run:
terraform destroy
00_provider.tf
: Configures the AWS provider.01_variables.tf
: Defines variables used in the configuration.02_s3.tf
: Creates an S3 bucket for the static website and configures static website hosting.03_s3_url.tf
: Outputs the URL of the static website.
- Modify the
terraform.tfvars
file to change thebucket_name
variable, which sets the name of the S3 bucket. - Update the
index.html
anderror.html
files in thewebsite-files
directory to customize the website content.
https://docs.aws.amazon.com/AmazonS3/latest/userguide/HostingWebsiteOnS3Setup.html
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_object