This repository is a part of my GitHub Actions: CI/CD and GitOps project. It contains terraform files that will create a custom VPC, subnets, and a three-node EKS cluster. All of this will be provisioned using GitHub Actions. I have made every necessary file public, so you can follow along and test this project as well.
Caution
This project is for testing purposes. It is strongly advised against using it for production.
/.github/workflows
: GitHub actions file/terraform
: Terraform files
- AWS CLI Setup
- Terraform CLI Setup
- GitHub Account
- AWS (EKS, S3)
- Terraform
- GitHub Actions
Note
My last build is intentionally failed as I removed my secrets for security purposes.
git clone https://github.com/YU88John/eks-ecr-gitops-tf.git
The GitHub Actions will be triggered based on the push
events to /terraform
directory.
We need terraform state to keep track of the state of actual infrastructure. If we don't have a state file, a whole new infrastructure will be created every time the push
event occurs. Read more about this.
For this project, we will create an S3 bucket to store that terraform state file. You can create via cli:
aws s3 mb --region us-east-1 s3://<your_unique_name>
To apply terraform from GitHub Actions, it needs permissions on AWS resources. Moreoever, the bucket name will also be fetched as a Secret. Create GitHub Secrets with the following keys and your respective values.
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
BUCKET_TF_STATE
You need to replace your values in /terraform/terraform.tf
. The snippet is as below:
backend "s3" {
bucket = ""
key = "terraform.tfstate"
region = "us-east-1"
}