
In previous chapters, you have been taking a largely manual approach to deploying both infrastructure and services. To be fair, leveraging the automation in the gcloud CLI and Cloud Run, in particular, has helped a lot, but it is still a manual process.
In Chapter 11, where you built the citadel (in particular, when configuring the API Gateway and Global HTTP Load Balancer), there was a lot of manual configuration and typing of commands. It was repetitive and error-prone, and if you wanted to deploy the application again, you would have to repeat the process.
Automating Build, Deployment, and Provisioning
This is a waste of time when you could be getting on with developing more features rather than fiddling with the command line. This type of work is known as “toil.” Toil is bad; toil should be eliminated when you see it. Toil is a sign that you need to automate something. When I first learned about software development at school, I was taught that when you have to do something more than twice, you should write a program to do it for you. This is one of those times that advice applies.
In this chapter, you will look at how you can use Google Cloud to automate away the toil you have been increasingly experiencing in previous chapters. You will also learn how this can be done for provisioning the infrastructure too.
NOTE
The code for this chapter is in the factory folder of the GitHub repository.
Requirements
You can think of what you are doing in this chapter as building a washing machine factory, the sort of place Sir John Harvey-Jones from Chapter 1 would visit. There are two things the factory produces:
Applications
The containerized services themselves. These can just be deployed in the citadel with everything in place they need. These are like the washing machine; you will create a pipeline that builds them and gets them ready to be delivered and plumbed in.
Infrastructure
Washing machines need infrastructure to run. Connections to electricity and water and a space under the worktop in a kitchen or utility room (if you are British like me). With the infrastructure in place, the washing machine can just be delivered, connected to water, plugged into electricity, and away you go. Not only can the factory make the washing machine, it can also make the pipes and cables it needs too.
When you are building a factory, you want it to provide the following, as shown in Figure 12-1:
• Somewhere to store source code like a silo for raw materials
• An automated build pipeline that acts like a robotic assembly line
• Somewhere to store the finished products; in this case, containers, like a warehouse
• An automated deployment mechanism like a truck with an installation engineer

Figure 12-1. The factory