AWS Code Pipeline with CloudFormation template (Part 2)

  • Published
  • Posted in AWS
  • Updated
  • 3 mins read
  • Tagged as

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

  1. Code Build Role : It has “CodeBuildCICDAccessPolicy” – with Code commit and S3 full access.
  2. Code Build Project
  3. Code Deploy Service Role : It has “CodeDeployCICDAccessPolicy” – with EC2, SNS, CloudWatch full access
  4. Code Deploy Application
  5. Code Deploy Deployment Group
  6. Code Pipeline SNS Service
  7. Code Pipeline Role : It has “CodePipelineCICDAccessPolicy” – with Code Commit, Code Build, S3, SNS, Code Deploy full access
  8. Code Pipeline with workflow
  9. Source : Code Commit
  10. Build : Code Build
  11. Staging : Code Deploy – code deployment on “dev” instances
  12. Production approval : Manual approval using SNS topic
  13. 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

Addend Analytics is a Microsoft Gold Partner based in Mumbai, India, and a branch office in the U.S.

Addend has successfully implemented 100+ Microsoft Power BI and Business Central projects for 100+ clients across sectors like Financial Services, Banking, Insurance, Retail, Sales, Manufacturing, Real estate, Logistics, and Healthcare in countries like the US, Europe, Switzerland, and Australia.

Get a free consultation now by emailing us or contacting us.