Best practices for cross-configuration communication
Stay organized with collections
Save and categorize content based on your preferences.
This page provides guidelines and recommendations for
cross-configuration communication when using Terraform for Google Cloud.
This guide is not an introduction to Terraform. For an introduction to using
Terraform with Google Cloud, see
Get started with Terraform.
A common problem that arises when using Terraform is how to share information
across different Terraform configurations (possibly maintained by different
teams). Generally, information can be shared between configurations without
requiring that they be stored in a single configuration directory (or even a
single repository).
The recommended way to share information between different Terraform
configurations is by using remote state to reference other root modules.
Cloud Storage
or
Terraform Enterprise
are the preferred state backends.
For querying resources that are not managed by Terraform, use data sources from
the
Google provider.
For example, the default Compute Engine service account can be retrieved
using a data source.
Don't use data sources to query resources that are managed by another Terraform
configuration. Doing so can create implicit dependencies on resource names and
structures that normal Terraform operations might unintentionally break.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-29 UTC."],[[["\u003cp\u003eThis page offers guidelines for cross-configuration communication in Terraform when working with Google Cloud.\u003c/p\u003e\n"],["\u003cp\u003eRemote state, using Cloud Storage or Terraform Enterprise, is recommended for sharing information between different Terraform configurations.\u003c/p\u003e\n"],["\u003cp\u003eUtilize data sources from the Google provider to query resources not managed by Terraform.\u003c/p\u003e\n"],["\u003cp\u003eAvoid using data sources to query resources managed by other Terraform configurations to prevent unintentional breaking changes.\u003c/p\u003e\n"]]],[],null,["# Best practices for cross-configuration communication\n\nThis page provides guidelines and recommendations for\ncross-configuration communication when using Terraform for Google Cloud.\n\nThis guide is not an introduction to Terraform. For an introduction to using\nTerraform with Google Cloud, see\n[Get started with Terraform](/docs/terraform/get-started-with-terraform).\n\nA common problem that arises when using Terraform is how to share information\nacross different Terraform configurations (possibly maintained by different\nteams). Generally, information can be shared between configurations without\nrequiring that they be stored in a single configuration directory (or even a\nsingle repository).\n\nThe recommended way to share information between different Terraform\nconfigurations is by using remote state to reference other root modules.\n[Cloud Storage](https://www.terraform.io/docs/backends/types/gcs.html)\nor\n[Terraform Enterprise](https://www.terraform.io/docs/backends/types/terraform-enterprise.html)\nare the preferred state backends.\n\nFor querying resources that are not managed by Terraform, use data sources from\nthe\n[Google provider](https://registry.terraform.io/providers/hashicorp/google/latest/docs).\nFor example, the default Compute Engine service account can be retrieved\n[using a data source](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_default_service_account).\nDon't use data sources to query resources that are managed by another Terraform\nconfiguration. Doing so can create implicit dependencies on resource names and\nstructures that normal Terraform operations might unintentionally break.\n\nWhat's next\n-----------\n\n- Learn about [best practices for version control](/docs/terraform/best-practices/version-control).\n- Learn about [best practices when working with Google Cloud resources](/docs/terraform/best-practices/working-with-resources)."]]