Giter Club home page Giter Club logo

s3_cloudfront_website_terraform's Introduction

Terraform for S3 Website with Cloudfront

Pre-req:

Learn about Terraform

My Terraform playlist on Youtube

Why I made this?

I made this Terraform to help others upload their simple websites to S3 using Cloudfront to distribute it. This will make a secure site that uses HTTPS and can allow you to connect anything into Lambda or other services. This is great for a small simple site to use for a blog, portfolio, or resume. I use this for my personal site and it is around 3 USD a month to run. This is much cheaper than most providers and is completely serverless and allows you to focus on your site itself. If you need any server side coding I would suggest using Lambda with the API service.

With Cloudfront it will automatically pull from the bucket every 24 hours to refresh with any changes, because versioning is enabled.

The root_bucket is strictly used to redirect to the www_bucket. I've also made this to automatically load all of your website files to the bucket if you have them inside of the website folder. So, make sure to populate it otherwise you'll need to upload them manually after it has run.

How to set-up this project for yourself.

  1. Download this repo locally.

    git clone https://github.com/b1tsized/s3_cloudfront_website_terraform.git

  2. Navigate to the folder you just downloaded.

    cd ./s3_cloudfront_website_terraform/

  3. Initialize the directory in Terraform.

    terraform init

  4. Update your variables in the terraform.tfvars file. If you need to use your AWS Access Key and Secret Key make sure to uncomment it in the variables.tf, terraform.tfvars, and providers.tf.

  5. Add all of your files for your website into the website folder.

  6. Check that everything is valid.

    terraform validate

  7. Run your plan to verify all changes in AWS.

    terraform plan

  8. Apply your changes.

    terraform apply

  9. Type yes to confirm changes.

  10. Wait for it to complete may take around 30 minutes with domain verification.

If you already have a Route53 Domain Zone.

If you already have a Route53 domain registered with zones you'll need to update all of the references to aws_route53_zone.bucket_domain to data.aws_route53_zone.bucket_domain.

I've made notes in both the route53.tf and acm.tf files.

Support

If you have any issues I'll try and help as best I can to debug or update. Just send me a message!

s3_cloudfront_website_terraform's People

Contributors

b1tsized avatar

Stargazers

Jim Stott avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.