Blue Green deployments is a technique for rapidly and repeatedly releasing changes to software in production.
- Go to EC2 instances in AWS and rename environment (EC2(s) in which you want to deploy the code) EC2(s) by appending -Blue in the end of the name of EC2.
- Create new EC2(s) by using following documentation Set Up - EC2.
- For new created EC2(s), add -Green in the end of the name of EC2.
- After provisioning EC2(s) from Step 2, Setup EC2 by using following documentation Set Up - EC2 Instance.
- Once Step 3 is completed, Now create new Target Group in AWS.
- Open Infra Set Up page, and look for Create Target Group from AWS console and follow those steps.
- After creating Target Group, Select newly created Target Group and register your EC2(s) created from Step 3.
- Now, go to Load Balancers, and select your ALB which is used in your environment infra.
- After selecting ALB, Go to Listeners tab.
- Click on View/edit rules under Rules column.
- Click on Edit icon which is present in page menu bar.
- Click on Edit icon which is present in the row where Rules are displaying.
- Click on Edit icon which is present in Then column, left side of Forward to.
- Select a target group select your new target from dropdown.
- For the existing Target group assign 100 for traffic distribution and for new Target group assign 0.
- Expand Group-level Stickiness and enable it for 1 days.
- Click on Tick icon and then click on Update button.
- Now go to Target Group, for your newly created Target Group check the Health Status. If it is healthy, then you good for code deployment.