In last blog we launched EC2 stack. It had two instances – dev and prod. It had Security Group with ports 22, 8080, 80 open, IAM policy for EC2 instances.
To refer to our Part 1 blog, click here.
In this blog, we will launch the template to deploy Code Pipeline.
To refer the template, click here.
The template has following things configured
- Code Build Role : It has “CodeBuildCICDAccessPolicy” – with Code commit and S3 full access.
- Code Build Project
- Code Deploy Service Role : It has “CodeDeployCICDAccessPolicy” – with EC2, SNS, CloudWatch full access
- Code Deploy Application
- Code Deploy Deployment Group
- Code Pipeline SNS Service
- Code Pipeline Role : It has “CodePipelineCICDAccessPolicy” – with Code Commit, Code Build, S3, SNS, Code Deploy full access
- Code Pipeline with workflow
- Source : Code Commit
- Build : Code Build
- Staging : Code Deploy – code deployment on “dev” instances
- Production approval : Manual approval using SNS topic
- Deploying to Prod : code deployment on “prod” instances
Proceed to Next. Keep rest settings as default and launch the template
Once created, you will get the notification to confirm the subscription for AWS SNS topic. Confirm it.
The template creates all the resources
As soon as stack has completed its resources creation, pipeline will get executed.
The screenshots above are of stages executed before manual approval.
Before manual approval : Since the pipeline is executed and deployed on dev instance, we can check the DNS of dev instance.
Prod instance DNS :
Since the latest code has yellow color for background of webpage. It is deployed on dev instance. It is not yet deployed on prod instance as it requires manual approval in the pipeline. Hence we are getting last code with green color on webpage.
To approve the changes in pipeline, you will get a notification email to approve.
Approve the same and let the pipeline execute on further stages.
After manual approval :
Dev instance :
Prod instance :
The changes are successfully deployed on instances with pipeline.
Now you can try making changes in Code Commit repo and wait for pipeline to get executed.
We will try to give green color in background to webpage.
The changes made in Code Commit has green color in background and message “This is welcome page V3.0”
Dev instance :
Prod instance :
The advantage of using CloudFormation template is the resources creation and deletion works on a single click. Do not forget to delete the resources. To do so, just delete the respective template and the resources will be deleted.
Shashank
Addend Analytics