Best practices for cross-configuration communication

This page provides guidelines and recommendations forcross-configuration communication when using Terraform for Google Cloud.

This guide is not an introduction to Terraform. For an introduction to usingTerraform with Google Cloud, seeGet started with Terraform.

A common problem that arises when using Terraform is how to share informationacross different Terraform configurations (possibly maintained by differentteams). Generally, information can be shared between configurations withoutrequiring that they be stored in a single configuration directory (or even asingle repository).

The recommended way to share information between different Terraformconfigurations is by using remote state to reference other root modules.Cloud Storage orTerraform Enterprise are the preferred state backends.

For querying resources that are not managed by Terraform, use data sources fromtheGoogle provider.For example, the default Compute Engine service account can be retrievedusing a data source.Don't use data sources to query resources that are managed by another Terraformconfiguration. Doing so can create implicit dependencies on resource names andstructures that normal Terraform operations might unintentionally break.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.