Create CodePipeline

Create CodePipeline

In this section, we will create a DevOps pipeline with the following actions:

A source stage with CodeCommit action

A build stage with CodeBuild action

A deployment stage with an Amazon ECS deploy action with Blue/Green Deployment.

  1. Sign in to the AWS Management Console and open the CodePipeline console

  2. On the Welcome page, Getting started page, or the Pipelines page, choose Create pipeline.

  3. In Step 1: Choose pipeline settings, in Pipeline name, enter codepipeline-tripmgmt-demo.

  4. In Service role, Choose New service role to allow CodePipeline to create a new service role in IAM. Enter name as codepipeline-tripmgmt-demo-service-role

    Codepipeline settings

  5. In Artifact store, Choose Default location to use the default artifact store, such as the Amazon S3 artifact bucket designated as the default, for your pipeline in the region you have selected for your pipeline.

  6. Choose Next.

  7. In Step 2: Add source stage, in Source provider, choose AWS CodeCommit. In Repository name, choose the name of the CodeCommit repository tripmgmtdemo. In Branch name, choose the name of the branch that contains your latest code update master

    Codepipeline Source stage

  8. Choose Next.

  9. In Step 3: Add build stage, in Build provider, choose AWS CodeBuild. In Project name choose the name of the build project.

    Codepipeline Build stage

  10. Choose Next.

  11. Choose Skip deploy stage and let first build complete.

  12. Review, review the information, and then choose Create pipeline.

Add Deploy Stage

  1. Open the CodePipeline console

  2. Choose default region from top section.

  3. Select the Pipeline name, For example codepipeline-tripmgmt-demo.

  4. Click Edit, and scroll down at bottom and “Add Stage” , give Stage name as BlueGreenDeployStage.

  5. Click Add action group, in Action name give action name Deploy-Tripmgmt-Demo-ECR.

  6. In Action provider, choose Amazon ECS (Blue/Green).

  7. In Input artifacts, choose SourceArtifact

  8. In AWS CodeDeploy application name, choose CodeDeploy Application name. In AWS CodeDeploy deployment group, choose CodeDeploy Application’s Deployment Group.

    CodeDeploy Stage Action 1

  9. In Amazon ECS task definition, choose SourceArtifact and enter taskdef.json

  10. In AWS CodeDeploy AppSpec file, choose SourceArtifact and enter appspec.yaml

    CodeDeploy Stage Action 2

  11. Choose Done

  12. Choose Save