Using CI/CD to Deploy Infrastructure to AWS with Terraform through Git Action
✨ Objective:
Provision a full AWS infrastructure using Terraform that includes:
- VPC with public and private subnets
- EKS (Elastic Kubernetes Service) cluster
- RDS (MySQL) database
- Route 53 for DNS management
- GitHub Actions self-hosted runner for automation
We already set up a Dockerized self-hosted GitHub runner.
The steps below shows the modules used by terraform to configure our infrastructure.
Step 1 Terraform Provider & Backend Setup
-
Configured the AWS Provider in provider.tf:
provider "aws" {
region = "eu-north-1"
profile = "default"
}
Step 2: VPC & Networking
Module used: module-vpc
- Created the VPC with a CIDR block of
192.168.0.0/16.
- Defined:
- Public Subnets for the NAT Gateway and internet access.
- Private Subnets for EKS nodes and RDS.
- Added an Internet Gateway.
- Deployed a NAT Gateway in one of the public subnets.