This repository includes the Terraform and Ansible files to provision following components,
- An EC2 instance exposed port 80 and 22
- Install nginx package by yum package manager
- Any neccessary resources on AWS
And two GitHub Actions workflow files for,
- Apply Terraform scripts and run Ansible playbook
- Upload Terraform state file to specified S3 bucket
- Upload Terraform dependencies lock file to specified S3 bucket
- Destroy all the resources created by Terraform
- Fork this repository
- Go to your repository's Settings > Secrets and variables > Actions
- Add 4 repository secrets by using the names as the image below
AWS_ACCESS_KEY_ID is your AWS access key ID
AWS_SECRET_ACCESS_KEY is your AWS secret access key
EC2_PRIVATE_KEY is the private key of your SSH key pair
EC2_PUBLIC_KEY is your public key of your SSH key pair
- Go to your repository's Actions
- Choose
Create a Nginx Web Server on your AWS account
from the left menu - Click the
Run workflow
button and fill your AWS region and S3 bucket name - Trigger the workflow
- Go to your repository's Actions
- Choose
Clean up all resources created by Terraform and Ansible
from the left menu - Click the
Run workflow
button and fill your AWS region and S3 bucket name - Trigger the workflow