Adding a continuous delivery step to our pipeline

As we saw in this chapter, pipelines are composed of stages. In CodePipeline, stages are characterized by their categories. We have explored three categories so far: source, deploy, and test. In order to add that confirmation step to deploy to production, we will use a new category called approval.

Approval actions offer a number of configuration options to get notifications when a job is pending approval. In order best to demonstrate it, we are going to create a new SNS topic and subscribe to it. SNS, as you might remember from Chapter 3, Treating Your Infrastructure As Code, is the Simple Notification Service that we used to create monitoring for our infrastructure.

We are going to use the command line to create a new topic and subscribe to it:

$ aws sns create-topic --name production-deploy-appoval
{
    "TopicArn": "arn:aws:sns:us-east-1:511912822958:production-deploy-
appoval"
}

We will use an email subscription, but SNS supports a number of other protocols such as SMS, HTTP, and SQS.

In order to subscribe, you need to know the TopicArn, which is in the output of the previous command:

$ aws sns subscribe --topic-arn 
      arn:aws:sns:us-east-1:511912822958:production-deploy-appoval 
      --protocol email 
      --notification-endpoint [email protected]
{
    "SubscriptionArn": "pending confirmation"
}  

Go to your inbox to confirm the subscription.

We can now add our new stages, starting with the approval stage:

  1. Open https://console.aws.amazon.com/codepipeline in your browser.
  2. Select the helloworld application.
  3. Click on Edit at the top of the pipeline.
  4. Click on the + Stage button at the bottom of the pipeline below the Beta stage.
  5. Give it the name Approval.
  6. Click on + Action.
  7. Select Approval in the Action Category menu.
  8. Call the action Approval.
  9. Select the approval type Manual approval.

 

  1. Pick the SNS topic we just created. Typing production deploy should let you find the topic easily thanks to the autocomplete feature of the form.
  2. Finally, click on Add action.

We are now going to add the deployment to production steps below this approval:

  1. Click on the + Stage button below the newly created stage Approval.
  2. Call this new stage Production.
  3. Click on + Action.
  4. Select the Deploy category.
  5. Call the action Production.
  6. Select the CodeDeploy provider.
  7. Pick helloworld as our application name.
  8. Select the deployment group production.
  9. Select the artifact MyApp.
  10. Click on Add action.
  11. Complete the creation of our new stages by clicking on save pipeline changes at the top of the pipeline.

We can once again click on Release change to test our updated pipeline.

The pipeline will go through the first three stages and then block on the approval stage. You can check your email inbox to find a link to provide your review or simply use the web interface and click on the review button in the approval stage:

After carefully reviewing the change on staging, approve or reject the change. If approved, the deployment will go to the last step of the pipeline and deploy the code to production.

We just completed automating our entire release process. Our Hello World application may not reflect what a real application might look like, but the pipeline we built around it does and what we built can be used as a blueprint for deploying more complex applications from environment to environment very safely in a well-thought-out process.

There is no question that your ability to move quickly and get customers in front of your new features and services is paramount to your ability to fight off disruption. The last step of building a continuous deployment pipeline is to remove that manual approval process to release code to production and take out the last step involving humans in the release process. Over the years, different companies have come up with a couple of strategies to make production deployments a safe process. Here are some solutions that you can implement.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset