VPC + EC2 + ALB + IGW + SG + RDS and finally integrate with github actions to CI / CD
- Deploy a VPC with CIDR 10.0.0.0/16
- Within the VPC we will have 2 public subnets with CIDR 10.0.1.0/24 and 10.0.2.0/24. Each public subnet will be in a different Availability Zone for high availability
- Create 2 private subnets with CIDR ‘10.0.3.0/24’ and ‘10.0.4.0/24’ and each will be in a different Availability Zone
- Deploy RDS MySQL instance.
- An Application load balancer that will direct traffic to the public subnets.
- Deploy one EC2 instance in each public subnet for high availability.
- Internet Gateway and Elastic IPs for EC2 instance.
- Install AWS CLI
- AWS Account
- Code Editor (I have used VS Code for this deployment)
Installation Guide
Step-1: Verify AWS CLI is installed on your local machine by following command
$ aws --version
aws-cli/2.22.33 Python/3.12.6 Windows/11 exe/AMD64
If you see the Outout above then skip the step-1, Else follow the below steps.
- Download the Installer:
- Go to the AWS CLI download page: AWS CLI Installer for Windows
- Download the MSI installer for Windows.
- Run the Installer:
- Locate the downloaded .msi file and double-click it.
- Follow the on-screen instructions in the setup wizard.
- Verify the Installation:
- Open a Command Prompt or PowerShell.
- Run the command
aws --version
- You should see ouput similar to:
aws-cli/2.x.x Python/x.x.x Windows/x.x
- Add AWS CLI to Path (if necessary):
- If the aws command is not recognized, ensure the installation directory (usually C:\Program Files\Amazon\AWSCLI) is added to your system's PATH environment variable.
- Download the AWS CLI Installer:
- Run the following command to download the AWS CLI installation script
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
- Unzip the Installer:
- Use unzip to extract the installer
unzip awscliv2.zip
- If unzip is not installed, install it using:
sudo apt install unzip # For Debian/Ubuntu sudo yum install unzip # For CentOS/Red Hat
- Run the Installer:
- Execute the installation script
sudo ./aws/install
- Verify the Installation:
- Run the following command to check if the AWS CLI is installed correctly
aws --version
- Output will look like:
aws-cli/2.x.x Python/x.x.x Linux/x.x
- Optional - Add to PATH:
- If the aws command isn't recognized, add /usr/local/bin to your PATH
export PATH=$PATH:/usr/local/bin
- You can add this line to your .bashrc or .zshrc file for persistence.
Step-2: Create Feature branch in gitbash terminal
- Open the gitbash terminal inside the project cloned directory
- Run the command:
git checkout -b feature
Step-3: To get an access key in AWS, you can:
- Sign in to the AWS Management Console
- Open the IAM console
- Select the user you want to create access keys for
- Select the Security credentials tab
- In the Access keys section, select Create access key
- Select Show to view the new access key pair
- Download the key file to your computer
Step-4: Post-Installation Steps:
- Configure AWS CLI:
- Run
aws configure
- Provide your Access Key ID, Secret Access Key, Default Region, and preferred output format (e.g., json or table).