chapter seven

7 CI/CD Pipelines as Code

 

This chapter covers:

  • Designing an end-to-end CI/CD pipeline for Docker containers on GCP
  • Enacting a two-stage strategy for deploying static and dynamic infrastructure
  • Iterating over complex types with for-each and dynamic blocks
  • Explicitly overriding default providers at the resource and module level
  • Creating custom resources with local-exec provisioners

CI/CD stands for Continuous Integration (CI) and Continuous Deployment (CD). It’s a DevOps methodology for enabling development teams to quickly ship code changes to production environments. CI/CD means changes are integrated faster, which results in smaller changes and decreased risk. This, in combination with the agility to deliver features faster is the key successes of CI/CD.

CI/CD is typically implemented by a CI/CD pipeline, which describes how code gets from version control systems through to end users and customers. In a CI/CD pipeline, each stage performs some discreet task, such as building, testing, and deploying, before automatically promoting to the next stage in the pipeline (see figure 7.1).

Figure 7.1 CI/CD stands for Continuous Integration (CI) and Continuous Deployment (CD). It’s normally implemented by a CI/CD pipeline, in which one stage automatically promotes into the next

7.1           A Tale of Two Deployments

7.2           CI/CD for Docker Containers on GCP

7.2.1   Designing the Pipeline

7.2.2   Detailed Engineering

7.3           Initial Workspace Setup

7.3.1   Organizing the Directory Structure

7.4           Dynamic Configurations and Provisioners

7.4.1   For-Each vs. Count

7.4.2   Executing Scripts with Provisioners

7.4.3   Null Resource with a Local-Exec Provisioner

7.4.4   Dealing with Repeating Configuration Blocks

7.4.5   Dynamic Blocks: Rare Boys

7.5           Configuring a Serverless Container

7.6           Deploying Static Infrastructure

7.7           CI/CD of a Docker Container

7.7.1   Publishing to Container Registry

7.7.2   Test Run the CI/CD Pipeline

7.8           Fireside Chat

7.9           Summary