Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nmcostello/terraform_website
https://github.com/nmcostello/terraform_website
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/nmcostello/terraform_website
- Owner: nmcostello
- Created: 2023-01-05T23:06:44.000Z (almost 2 years ago)
- Default Branch: development
- Last Pushed: 2023-02-25T18:34:45.000Z (almost 2 years ago)
- Last Synced: 2023-10-12T14:57:41.351Z (about 1 year ago)
- Language: HCL
- Size: 456 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Deploy a highly-available webserver
#### Table of Contents
[Overview](#overview)
[Directory layout](#directory-layout)
[How to use](#how-to-use)
[Architecture](#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](.github/workflows): hosts all the files relating to GitHub Actions.
- [deployment.yaml](.github/workflows/deployment.yaml): contains the code for the job that deploys Terraform.
- [docs.yaml](.github/workflows/docs.yaml): contains the code for the job that builds the Terraform docs.
- [image.yaml](.github/workflows/image.yaml): contains the job code that runs Packer.
- [packer](packer): hosts all the files related to Packer and the image that it builds.
- [index.html](packer/index.html): index page for the webserver.
- [website](packer/website): NGINX server configuration.
- [webserver.pkr.hcl](packer/webserver.pkr.hcl): Packer configuration to build the AMI.
- [terraform](terraform): contains all of the Terraform IAC.
- [README.md](terraform/README.md): README generated by Terraform docs job in pipeline.
- [main.tf](terraform/main.tf): main Terraform file.
- [dns.tf](terraform/dns.tf): contains code related to DNS, certificates, and CNAME associtation.
- [loadbalancer.tf](terraform/loadbalancer.tf): contains code relating to the load balancer.
- [variables.tf](terraform/variables.tf): variables files.
- [webserver.tf](terraform/webserver.tf): contains code that deploys server, autoscaling group, and launch config
- [outputs.tf](terraform/outputs.tf): outputs from Terraform deployment.
- [test](test): test directory
- [validate.py](test/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. |
3. Push a commit, and the pipeline will run.
4. You will have a new site on `https://challenge.${domain}`## Architecture
![Architecture](arch.excalidraw.png)