GithubHelp home page GithubHelp logo

kryndex / terraform-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mdb/terraform-example

0.0 2.0 0.0 4.23 MB

Terraform-orchestrated continuous delivery from TravisCI

Shell 5.07% JavaScript 33.53% CSS 34.03% HTML 3.89% HCL 23.47%

terraform-example's Introduction

Build Status

terraform-example

A reference repo demonstrating how to continuously deploy via terraform from TravisCI.

Via TravisCI (or locally), use Node.js to compile a static website; use Terraform to:

  • create www.your-domain.com and your-domain.com AWS S3 buckets configured for static website hosting
  • redirect requests to the www.your-domain.com bucket to your-domain.com
  • deploy the index.html and error.html objects to the your-domain.com bucket
  • establish an AWS Route53 your-domain.com DNS zone
  • establish a Route53 A record set pointing your-domain.com to the your-domain.com S3 bucket

TravisCI build flow

TravisCI:

  1. Uses Node.js to compile src to a static website.
  2. If the branch is master, installs terraform
  3. If the branch is master, executes deploy.sh to deploy the static website to AWS S3 website fronted by mikeball.me via:
  4. terraform plan
  5. terraform apply
  6. commit terraform.tfstate back to this repo with a [ci skip] commit message such that a TravisCI build is not triggered.

Giving it a spin

To deploy your own:

  1. Fork this repo.

  2. Visit travis-ci.org; activate CI for your fork of this repo.

  3. Install the travis CLI if you don't already have it:

$ gem install travis
  1. Use the travis CLI to encrypt your AWS credentials and your Github access token in environment variables:
$ travis encrypt AWS_ACCESS_KEY_ID=123 AWS_SECRET_ACCESS_KEY=456 GH_TOKEN=123
  1. Add the encrypted credentials string to your .travis.yml, replacing the current secure value:
...
  env:
    secure: "ENCRYPTED STRING HERE"
...
  1. Replace GH_USER_NAME, GH_USER_EMAIL, and GH_REPO in the .travis.yml with your details.

  2. Replace the domain var in terraform/main.tf with your domain name.

  3. Remove my tfstate files to start fresh:

$ git rm terraform/terraform.tfstate*
$ git commit -m 'removed mdb tfstate'
  1. Push & deploy:
$ git push origin master
  1. Note that you may need to point the DNS servers associated with your-domain.com to those dynamically assigned to your A record by AWS. For example, my A record uses these DNS servers.

terraform-example's People

Contributors

mdb avatar

Watchers

 avatar  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.