Overview
Directory layout
How to use
Architecture
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
usingPacker
AMI for the NGINX webservers.
- .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.
- index.html: index page for the webserver.
- website: NGINX server configuration.
- webserver.pkr.hcl: Packer configuration to build the AMI.
- 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.
- Github Account
- AWS Account
- A registered doamin
- If you want to run this locally you will also need:
- AWS CLI
- Terraform CLI
- Packer CLI
- Fork the repo into your own GitHub Account
- Add the following secrets to your GitHub secrets:
- or to a local
terraform.tfvars
file if you are running locally.
- or to a local
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. |
- Push a commit, and the pipeline will run.
- You will have a new site on
https://challenge.${domain}