Provisioning Redis and connecting it via a VPC connector
Note
The code for this section can be found in the chap07/foundation
directory in this book’s GitHub repository.
Similar to what we did in the previous chapter, we will start by building the foundation. This architecture requires several project services, a service account, and a VPC with one subnet. As we used the same setup in the previous chapter, we can simply reuse the code from the previous chapter by copying the following files:
project-services.tf
sa.tf
vpc.tf
We only need to change our variable assignments in terraform.tfvars
.
Note
Of course, it would be even more efficient to create modules and then use them.
Provisioning a basic Redis instance in Google Cloud using Terraform only requires a few lines of code. However, for a Cloud Run service to connect to Redis, we need to create a VPC connector (https://cloud.google.com/vpc/docs/configure-serverless-vpc-access).
Here...