Laying the foundation
Note
The code for this section is under the chap06/foundation
directory in the GitHub repository of this book. Please note that we divided the code into small files for readability purposes.
In the first layer, we set the foundation for this architecture. First, we enable the appropriate APIs using the google_project_service
resource. For this project, we require the following APIs:
- Cloud Resource Manager
- Compute Engine
- Identity and Access Management
- Secret Manager API
The google_project_service
resource has an optional argument, disable_on_destroy
, which is set to true
by default. It is usually better to set it to false
, which mimics the behavior when we enable APIs using the web console.
As we are creating multiple google_project_service
resources, this is an ideal opportunity to use the for_each
meta-argument. for_each
requires a set – we use the toset()
function which converts a list to a set. This function is useful...