Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

terraform download of foundations blueprint 'provider_meta.module_name' purpose/location?

Hi, 

Having gone through the process of using the 'Google Cloud Setup' in the Google Cloud Console, I downloaded the resulting terraform but am at a loss to where it refers to 'provider_meta' & 'module_name' in 'versions.tf'. The module name being referred to isn't part of the downloaded files and neither can I see it as part of the storage bucket that was set up when downloading the terraform code. So I'd like to know please what this code is doing, is it referring to a bespoke version of the providers and if so where is the module and why would this be necessary over just referring to the providers?

I've changed part of the 'module_name' variable below to remove the seemingly random string value and substituted it for '<stringvar>' as I don't know if it is sensitive information. This '<stringvar>' changes if I redownload the terraform so for some reason it seems something is done behind the scenes that relates to my specific input to the 'Google Cloud Setup' process.

This 'versions.tf' file...

 

terraform {
  required_version = ">= 1.3"

  required_providers {
    google = {
      source  = "hashicorp/google"
      version = ">= 5.22"
    }
    google-beta = {
      source  = "hashicorp/google-beta"
      version = ">= 5.22"
    }
  }
  provider_meta "google" {
    module_name = "blueprints/terraform/fs-exported-<stringvar>/v0.1.0"
  }
  provider_meta "google-beta" {
    module_name = "blueprints/terraform/fs-exported-<stringvar>/v0.1.0"
  }
}

 

 Thanks in advance for any assistance you can offer me as I'm new to GCP & Terraform.

 

 

0 1 502
1 REPLY 1

Hi @justin-cloud,

Welcome to Google Cloud Community!

To begin with, Google Cloud Setup helps you to configure Google cloud for scalable workloads. The setups process guides you through an interactive procedure that helps you create a foundational architecture with best practices. The Google Cloud Setup uses an Enterprise foundations blueprint which lets you deploy a foundational set of resources in Google Cloud. 

To differentiate between Module and Blueprints, a module is a reusable set of Terraform configuration files that creates a logical abstraction of Terraform resources, while Blueprint is a package of deployable, reusable modules and policy that implements and documents a specific opinionated solution. Deployable configuration for all Terraform blueprints are packaged as Terraform modules.

The versions.tf file content is a description of the providers needed by each specific module and, if needed, the version of Terraform that module is intended to support.

To interpret the terraform command in the version.tf file, here is the breakdown for each command:

  • The required_version command specifies which versions of Terraform can be used with your configuration.
terraform { 
   required_version = ">= 1.3" 
  • The required_providers block specifies all of the providers required by the current module, mapping each local provider name to a source address and a version constraint.
    • Source attribute is defined as “hashicorp/google” for Google provider
    • Version attribute is optional, but it's recommended to use it to enforce the provider version. Without it, Terraform will always use the latest version of the provider, which may introduce breaking changes.
  required_providers {
      google = {
      source = "hashicorp/google" 
      version = ">= 5.22" 
     }
      google-beta = { 
      source = "hashicorp/google-beta" 
      version = ">= 5.22" 
     } 
   }
}
  • The provider_meta block is used to provide additional metadata about a specific provider and used for versioning of the specific module. 
    • Module_name attributes help to associate the provider with a specific Terraform module.  
      • blueprints/terraform/fs-exported- - directory where the module code resides
      • <stringvar> - a variable that gets inserted into the module
      • V0.1.0 - This is the module’s version
provider_meta "google" { 
      module_name ="blueprints/terraform/fs-exported-<stringvar>/v0.1.0"
     }
provider_meta "google-beta" { 
      module_name ="blueprints/terraform/fs-exported-<stringvar>/v0.1.0"
     } 
}

 Since you said that you are new to GCP and Terraform I would like to recommend these documentations to guide you on your journey in GCP. 

I hope the above information is helpful.