Skip to content

IaC for a highly-available web server deployment into AWS

Notifications You must be signed in to change notification settings

nmcostello/terraform_website

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deploy a highly-available webserver

Table of Contents

Overview
Directory layout
How to use
Architecture

Overview

This project uses Packer and Terraform to create and configure a highly-available website. The project has the following components:

  • GitHub Actions: the workflows are used to validate, test, and deploy the Packer, Terraform, and documentation code.
  • Packer: creates an Ubuntu AMI and installs and configures NGINX on the image that is later used in the Terraform step.
  • Terraform: IaC used to deploy resources to AWS:
    • Route53: DNS and CNAME records.
    • ACM: SSL Cert for HTTPS.
    • Application Load Balancer: balances load to webservers, redirects HTTP -> HTTPS.
    • Autoscaling Group using Packer AMI for the NGINX webservers.

Directory layout

  • .github/workflows: hosts all the files relating to GitHub Actions.
    • deployment.yaml: contains the code for the job that deploys Terraform.
    • docs.yaml: contains the code for the job that builds the Terraform docs.
    • image.yaml: contains the job code that runs Packer.
  • packer: hosts all the files related to Packer and the image that it builds.
  • terraform: contains all of the Terraform IAC.
    • README.md: README generated by Terraform docs job in pipeline.
    • main.tf: main Terraform file.
    • dns.tf: contains code related to DNS, certificates, and CNAME associtation.
    • loadbalancer.tf: contains code relating to the load balancer.
    • variables.tf: variables files.
    • webserver.tf: contains code that deploys server, autoscaling group, and launch config
    • outputs.tf: outputs from Terraform deployment.
  • test: test directory
    • validate.py: Python script to validate webserver configuration.

How to use

Prerequisites

  • Github Account
  • AWS Account
  • A registered doamin
  • If you want to run this locally you will also need:
    • AWS CLI
    • Terraform CLI
    • Packer CLI

Steps

  1. Fork the repo into your own GitHub Account
  2. Add the following secrets to your GitHub secrets:
    • or to a local terraform.tfvars file if you are running locally.
Secret Description
AWS_ACCESS_KEY_ID Access key for IAM user in your account.
AWS_SECRET_ACCESS_KEY Secret access key for IAM user in your account.
DOMAIN Domain name that you own and want to deploy to.
VPC_ID VPC ID to deploy to.
  1. Push a commit, and the pipeline will run.
  2. You will have a new site on https://challenge.${domain}

Architecture

Architecture

About

IaC for a highly-available web server deployment into AWS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published