Skip to content

IaC for hosting static websites on Amazon S3 using Terraform.

License

Notifications You must be signed in to change notification settings

adil6572/terraform-s3-hosting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Amazon S3 Static Website Hosting

This project demonstrates how to host a static website on Amazon S3 using Terraform.

Table of Contents

  1. Overview
  2. Prerequisites
  3. Installation
  4. Usage
  5. Configuration
  6. License
  7. Authors
  8. Acknowledgements

Overview

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.

Prerequisites

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.

Installation

To install and deploy the project, follow these steps:

  1. Clone the repository to your local machine:

    git clone https://github.com/adil6572/terraform-s3-hosting.git
    
  2. Change into the project directory:

    cd terraform_s3_hosting
  3. Initialize Terraform:

    terraform init

Configuration

Variables

The project uses the following variables defined in variables.tf:

  • bucket_name: The name of the S3 bucket to host the website.

File Structure

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:

Usage

To deploy the static website to Amazon S3, follow these steps:

  1. Configure your AWS credentials using AWS CLI if you haven't already:

    aws configure
  2. Review and adjust the s3.tfvars file with your desired configurations.

  3. Apply the Terraform configuration to create the infrastructure:

    terraform apply -var-file=s3.tfvars

License

This project is licensed under the MIT License.

Authors

Acknowledgements

  • Special thanks to the Terraform community for their excellent documentation and resources.

Releases

No releases published

Packages

No packages published