Code Monkey home page Code Monkey logo

terraform-static-site-pipeline's Introduction

Bootstraping the easy way to deploy Static Sites on S3

This is a reference to scale DevOps Workflows to Designers and Front End Developers to prototyping, validate and deploy landing pages, React, Vue, Angular Apps.

1. Stack

Issue Technology
Git Manager Github
Infrastructure Provisioning Terraform - Hashicorp IaC Multicloud Manager
Pipeline / Build Platform CodePipeline + CodeBuild from AWS
Hosting System Amazon S3 - Low Cost Object Storage with Website feature on AWS
Caching / CDN System Amazon Cloudfront - AWS Global Content Delivery Network

2. Basic Architecture

Design

3. Project Configuration

Edit the config.tf file and input the Github, Project Name, Develop and Production branches e etc.

Example:

variable "app_name" {
  description = "Website project name"
  default     = "raj-personal-site"
}

variable "aws_region" {
  description = "AWS Region for the VPC"
  default     = "us-east-1"
}

variable "git_repository_owner" {
  description = "Github Repository Owner"
  default     = "msfidelis"
}

variable "git_repository_name" {
  description = "Project name on Github"
  default     = "msfidelis.github.io"
}

variable "git_repository_branch" {
  description = "Github Project Branch"
  default     = "master"
}

# Optional
variable "git_repository_dev_branch" {
  description = "Github Project Branch"
  default     = "develop"
}

2. Edit your build specs

You can edit your build specs in modules/website/templates/buildspec.yml

version: 0.2

phases:
  pre_build:
    commands:
      - echo Deploy website
  build:
    commands:
      - echo "add your steps and scripts here"
      - rm -rf .git
      - aws s3 sync --delete . s3://${bucket_name} --cache-control max-age=3600
  post_build:
    commands:
      - echo 'Invalidating distribuition cache'
      - aws cloudfront create-invalidation --distribution-id ${distribuition_id} --paths "/*"

2. Setup Github Access Token

export GITHUB_TOKEN=YOUR_TOKEN

3. Validate and Deploy

  • Initialize Terraform
terraform init
  • Plan our modifications
terraform plan
  • Apply the changes on AWS
terraform apply
  • Go to Codepipeline Dashboard on AWS Console

site deployed

  • Access your S3 Bucket output

site deployed

terraform-static-site-pipeline's People

Contributors

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