Sharing modules using Google Cloud Storage and Git repositories
Note
The code for this section is under the chap04/local-module
directory in the GitHub repo of this book.
Modules that are contained within our code are known as local modules. If we want to share a module with other projects or other people, we can store modules in various locations, including Google Cloud Storage (GCS) and Git repositories. To use a module stored in GCS, we will use the gcs::
prefix followed by the bucket URL, as in the following example:
source = "gcs::https://www.googleapis.com/storage/v1/terraform-for-gcp/modules/server"
We can store the module either as individual files or as a compressed file using zip or gzip. Thus, the following is also valid:
source = "gcs::https://www.googleapis.com/storage/v1/terraform-for-gcp/modules/server.tar.gz"
Please note that you must have the right Identity and Access Management (IAM) permission...