AWS-Blue-Green-Deployment-Project
π§© Project Overview
This project demonstrates a Blue/Green Deployment architecture using AWS Elastic Beanstalk for zero-downtime application updates.
It integrates RDS (MySQL) for persistent data storage and S3 for file uploads.
-
Blue environment → Stable production version
-
Green environment → New release version
AWS Services Used:
- VPC
- Elastic Beanstalk
- EC2{inside EB}
- RDS{MySQL}
- S3 Bucket
- IAM Roles
- Security Group
- CloudWatch Logs
Source Code (GitHub)π (https://github.com/bilsgotchills/blue-green-deployment.git)
Step 1: Create IAM roles
(a) For Elastic Beanstalk Service Role - Add permission
- AWSElasticBeanstalkManagedUpdatesCustomerRolePolicy
- AWSElasticBeanstalkEnhancedHealth
(b) For EC2 Instance Profile Role
- AWSElasticBeanstalkWebtier
- S3fullAccess
- CloudWatchLogFullAccess
- AWSElasticBeanstalkWorkerTier
Step2: Create a RDS MySQL Database
Step 3: Create a S3 Bucket. "ElasticBeanstalk-bucket"
Step 4: Deploy the Blue Environment
- Create an Elastic Beanstalk PHP environment named "Blue-webapp-env"
- Upload and deploy "php-blue-app.zip" file
- "php-blue-app" contains = "index.php" , "upload.php" , ".ebextensions/php-settings.confog"
- Select Private subnet for EC2
- Attach the Policies
- Select Atleast 2 Public subnet for Application Load Balancer : Min 2 , Desired 2 and Max 3
- Auto Scaling Triggers :
- CPUUtilization | Statistic =Average | Unit = Percent | Upper threshold = 75 (+1) | Lower threshold = 25 (-1)
- Deployment Policy chose Rolling Updates = Batch Size (Percentage) = 50%
- Configure Environments variables
- Add inbound rule in RDS _security _group = Type → MySQL/Aurora , Port range →3306, Source → Security_group_of_EC2
- Wait until health = Green → verify RDS connection and S3 upload .
- Blue-web-app deploys successfully
Step 5: Clone Blue-web-app to Create Green-webapp-env
- Clone Environment
- Name is "green-webapp-env"
- Deploy the "php-green-app.zip" file → shows a green header "GREEN ENV - Version 2"
Step 6: Test the Green Environment
- Confirm DB connections works .
- Upload files to the same S3 bucket.
- Ensure both environments point to the same RDS instance.
- When the Green Version is fully tested → Swap the URLs → Production traffic moves instantly to Green (zero downtime)
- Blue stays as a rollback backup.
- Configure Elastic Beanstalk environments , security group and subnets correctly.
- Manage IAM permission securely.
- Perform Blue/Green deployments and rolling updates confidently.
- Understanding Auto scalling triggers , Load Balancing and Zero downtime Deployment strategies.
(a) Problem : Elastic Beanstalk environment used uppercase varaiables names like DB_HOST,DB_USER but the PHP code referenced lowercase ones (dbhost).this caused "DB environment variables not set " errors and DB connection failures.
Solution : Updated all the PHP code to use uppercase env varaiables consistently (getenv("DB_HOST"),etc)-.Redeployed and the connection to RDS worked immediately .
(b) Problem: While using custom VPC , the EC instances couldn't reached the internet to download Composer dependencies .
Root Cause : Instances were in Private subnets without a NAT Gateway.
Solution:
(1) Add NAT Gateway to a public subnet.(2) Updated Private Route Table - route all traffic 0.0.0.0/0 - NAT Gateway
(3) EB deployment completed sucessfully.
Comments
Post a Comment