Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Values inferred from interpolated provider block not passed to datasource #21493

Closed
rileykarson opened this issue May 28, 2019 · 3 comments
Closed
Labels
config enhancement v0.11 Issues (primarily bugs) reported against v0.11 releases v0.12 Issues (primarily bugs) reported against v0.12 releases

Comments

@rileykarson
Copy link
Contributor

rileykarson commented May 28, 2019

Terraform Version

$ terraform -v
Terraform v0.12.0
+ provider.google v2.7.0

Terraform Configuration Files

# This is only used to create the project itself

provider "google" {
  version     = ">= 2.5.1, < 3.0.0"
  alias       = "project"
  region      = "us-central1"
}

# This is the default provider used to create all resources within the project

provider "google" {
  version     = ">= 2.5.1, < 3.0.0"
  project     = google_project.it.id
  region      = "us-central1"
}

resource "google_project" "it" {
  provider            = "google.project"
  name                = "my-project"
  project_id          = "my-project-######"
  auto_create_network = false
  billing_account     = "######-######-######"
}

data "google_compute_zones" "us" {
  region = "us-central1"
}

Debug Output

$ TF_LOG=DEBUG terraform apply
2019/05/28 10:36:19 [INFO] Terraform version: 0.12.0
2019/05/28 10:36:19 [INFO] Go runtime version: go1.12.5
2019/05/28 10:36:19 [INFO] CLI args: []string{"/Users/rileykarson/homebrew/bin/terraform", "apply"}
2019/05/28 10:36:19 [DEBUG] Attempting to open CLI config file: /Users/rileykarson/.terraformrc
2019/05/28 10:36:19 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2019/05/28 10:36:19 [INFO] CLI command args: []string{"apply"}
2019/05/28 10:36:19 [DEBUG] New state was assigned lineage "397855d6-c0f6-2563-2310-9546bd219d16"
2019/05/28 10:36:19 [DEBUG] checking for provider in "."
2019/05/28 10:36:19 [DEBUG] checking for provider in "/Users/rileykarson/homebrew/bin"
2019/05/28 10:36:19 [DEBUG] checking for provider in ".terraform/plugins/darwin_amd64"
2019/05/28 10:36:19 [DEBUG] found provider "terraform-provider-google_v2.7.0_x4"
2019/05/28 10:36:19 [DEBUG] checking for provider in "/Users/rileykarson/.terraform.d/plugins"
2019/05/28 10:36:19 [WARN] found legacy provider "terraform-provider-google"
2019/05/28 10:36:19 [WARN] found legacy provider "terraform-provider-google-beta"
2019/05/28 10:36:19 [DEBUG] found valid plugin: "google", "0.0.0", "/Users/rileykarson/.terraform.d/plugins/terraform-provider-google"
2019/05/28 10:36:19 [DEBUG] found valid plugin: "google-beta", "0.0.0", "/Users/rileykarson/.terraform.d/plugins/terraform-provider-google-beta"
2019/05/28 10:36:19 [DEBUG] found valid plugin: "google", "2.7.0", "/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4"
2019/05/28 10:36:19 [DEBUG] checking for provisioner in "."
2019/05/28 10:36:19 [DEBUG] checking for provisioner in "/Users/rileykarson/homebrew/bin"
2019/05/28 10:36:19 [DEBUG] checking for provisioner in ".terraform/plugins/darwin_amd64"
2019/05/28 10:36:19 [DEBUG] checking for provisioner in "/Users/rileykarson/.terraform.d/plugins"
2019/05/28 10:36:19 [INFO] backend/local: starting Apply operation
2019-05-28T10:36:19.775-0700 [INFO]  plugin: configuring client automatic mTLS
2019-05-28T10:36:19.800-0700 [DEBUG] plugin: starting plugin: path=/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4 args=[/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4]
2019-05-28T10:36:19.805-0700 [DEBUG] plugin: plugin started: path=/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4 pid=71776
2019-05-28T10:36:19.805-0700 [DEBUG] plugin: waiting for RPC address: path=/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4
2019-05-28T10:36:19.823-0700 [INFO]  plugin.terraform-provider-google_v2.7.0_x4: configuring server automatic mTLS: timestamp=2019-05-28T10:36:19.822-0700
2019-05-28T10:36:19.849-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: plugin address: network=unix address=/var/folders/81/zf5_7yzn1sxg_7kfkqsvgclw00cn8c/T/plugin974069367 timestamp=2019-05-28T10:36:19.849-0700
2019-05-28T10:36:19.849-0700 [DEBUG] plugin: using plugin: version=5
2019-05-28T10:36:19.926-0700 [DEBUG] plugin: plugin process exited: path=/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4 pid=71776
2019-05-28T10:36:19.926-0700 [DEBUG] plugin: plugin exited
2019/05/28 10:36:19 [DEBUG] ReferenceTransformer: "google_project.it" references: []
2019/05/28 10:36:19 [DEBUG] ReferenceTransformer: "data.google_compute_zones.us" references: []
2019/05/28 10:36:19 [DEBUG] ReferenceTransformer: "provider.google.project" references: []
2019/05/28 10:36:19 [DEBUG] ReferenceTransformer: "provider.google" references: [google_project.it]
2019-05-28T10:36:19.930-0700 [INFO]  plugin: configuring client automatic mTLS
2019-05-28T10:36:19.958-0700 [DEBUG] plugin: starting plugin: path=/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4 args=[/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4]
2019-05-28T10:36:19.963-0700 [DEBUG] plugin: plugin started: path=/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4 pid=71777
2019-05-28T10:36:19.963-0700 [DEBUG] plugin: waiting for RPC address: path=/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4
2019-05-28T10:36:19.979-0700 [INFO]  plugin.terraform-provider-google_v2.7.0_x4: configuring server automatic mTLS: timestamp=2019-05-28T10:36:19.978-0700
2019-05-28T10:36:20.004-0700 [DEBUG] plugin: using plugin: version=5
2019-05-28T10:36:20.004-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: plugin address: address=/var/folders/81/zf5_7yzn1sxg_7kfkqsvgclw00cn8c/T/plugin655700132 network=unix timestamp=2019-05-28T10:36:20.004-0700
2019-05-28T10:36:20.093-0700 [DEBUG] plugin: plugin process exited: path=/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4 pid=71777
2019-05-28T10:36:20.093-0700 [DEBUG] plugin: plugin exited
2019-05-28T10:36:20.093-0700 [INFO]  plugin: configuring client automatic mTLS
2019-05-28T10:36:20.121-0700 [DEBUG] plugin: starting plugin: path=/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4 args=[/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4]
2019-05-28T10:36:20.128-0700 [DEBUG] plugin: plugin started: path=/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4 pid=71778
2019-05-28T10:36:20.128-0700 [DEBUG] plugin: waiting for RPC address: path=/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4
2019-05-28T10:36:20.143-0700 [INFO]  plugin.terraform-provider-google_v2.7.0_x4: configuring server automatic mTLS: timestamp=2019-05-28T10:36:20.143-0700
2019-05-28T10:36:20.167-0700 [DEBUG] plugin: using plugin: version=5
2019-05-28T10:36:20.167-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: plugin address: address=/var/folders/81/zf5_7yzn1sxg_7kfkqsvgclw00cn8c/T/plugin509424801 network=unix timestamp=2019-05-28T10:36:20.167-0700
2019-05-28T10:36:20.251-0700 [DEBUG] plugin: plugin process exited: path=/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4 pid=71778
2019-05-28T10:36:20.251-0700 [DEBUG] plugin: plugin exited
2019/05/28 10:36:20 [INFO] terraform: building graph: GraphTypeRefresh
2019/05/28 10:36:20 [TRACE] No managed resources in state during refresh; skipping managed resource transformer
2019/05/28 10:36:20 [DEBUG] ReferenceTransformer: "provider.google" references: []
2019/05/28 10:36:20 [DEBUG] ReferenceTransformer: "data.google_compute_zones.us" references: []
2019/05/28 10:36:20 [TRACE] Completed graph transform *terraform.ReferenceTransformer (no changes)
2019/05/28 10:36:20 [TRACE] Executing graph transform *terraform.TargetsTransformer
2019/05/28 10:36:20 [DEBUG] Starting graph walk: walkRefresh
2019-05-28T10:36:20.252-0700 [INFO]  plugin: configuring client automatic mTLS
2019-05-28T10:36:20.276-0700 [DEBUG] plugin: starting plugin: path=/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4 args=[/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4]
2019-05-28T10:36:20.281-0700 [DEBUG] plugin: plugin started: path=/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4 pid=71779
2019-05-28T10:36:20.281-0700 [DEBUG] plugin: waiting for RPC address: path=/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4
2019-05-28T10:36:20.295-0700 [INFO]  plugin.terraform-provider-google_v2.7.0_x4: configuring server automatic mTLS: timestamp=2019-05-28T10:36:20.295-0700
2019-05-28T10:36:20.323-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: plugin address: address=/var/folders/81/zf5_7yzn1sxg_7kfkqsvgclw00cn8c/T/plugin200295246 network=unix timestamp=2019-05-28T10:36:20.323-0700
2019-05-28T10:36:20.323-0700 [DEBUG] plugin: using plugin: version=5
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Authenticating using configured Google JSON 'credentials'...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO]   -- Scopes: [https://www.googleapis.com/auth/compute https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/ndev.clouddns.readwrite https://www.googleapis.com/auth/devstorage.full_control]
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating GCE client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating GCE Beta client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating GKE client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating GKE Beta client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud DNS client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud DNS Beta client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud KMS Client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Stackdriver Logging client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Storage Client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google SqlAdmin Client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Pubsub Client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Dataflow Client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud ResourceManager Client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud ResourceManager V Client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud Runtimeconfig Client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud IAM Client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud IAMCredentials Client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud Service Management Client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud Service Usage Client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud Billing Client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud Build Client...
2019-05-28T10:36:20.398-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud BigQuery Client...
2019-05-28T10:36:20.399-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud CloudFunctions Client...
2019-05-28T10:36:20.399-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud Source Repo Client...
2019-05-28T10:36:20.399-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud Spanner Client...
2019-05-28T10:36:20.399-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud Dataproc Client...
2019-05-28T10:36:20.399-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud IoT Core Client...
2019-05-28T10:36:20.399-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating App Engine Client...
2019-05-28T10:36:20.399-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Cloud Composer Client...
2019-05-28T10:36:20.399-0700 [DEBUG] plugin.terraform-provider-google_v2.7.0_x4: 2019/05/28 10:36:20 [INFO] Instantiating Google Cloud Storage Transfer Client...
2019/05/28 10:36:20 [DEBUG] Resource state not found for node "data.google_compute_zones.us", instance data.google_compute_zones.us
2019/05/28 10:36:20 [TRACE] Completed graph transform *terraform.AttachStateTransformer (no changes)
2019/05/28 10:36:20 [DEBUG] ReferenceTransformer: "data.google_compute_zones.us" references: []
data.google_compute_zones.us: Refreshing state...
2019/05/28 10:36:20 [ERROR] <root>: eval: *terraform.EvalReadData, err: project: required field is not set
2019/05/28 10:36:20 [ERROR] <root>: eval: *terraform.EvalSequence, err: project: required field is not set

Error: project: required field is not set

  on main.tf line 25, in data "google_compute_zones" "us":
  25: data "google_compute_zones" "us" {


2019-05-28T10:36:20.405-0700 [DEBUG] plugin: plugin process exited: path=/Users/rileykarson/terraform-test/provider2/.terraform/plugins/darwin_amd64/terraform-provider-google_v2.7.0_x4 pid=71779
2019-05-28T10:36:20.405-0700 [DEBUG] plugin: plugin exited

Expected Behavior

The datasource is read after the project, can infer the project based on the provider config

Actual Behavior

The datasource was read before the provider had interpolated the project value.

Steps to Reproduce

  1. terraform init
  2. terraform apply

Additional Context

This works when creating a resource.

References

This is based on hashicorp/terraform-provider-google#3730

@craigwatson
Copy link

craigwatson commented May 28, 2019

FWIW, this also happens on TF 0.11.14:

* data.google_compute_zones.us: 1 error occurred:
* data.google_compute_zones.us: data.google_compute_zones.us: project: required field is not set

@hashibot hashibot added v0.12 Issues (primarily bugs) reported against v0.12 releases v0.11 Issues (primarily bugs) reported against v0.11 releases config enhancement and removed bug labels Aug 22, 2019
@teamterraform
Copy link
Contributor

Hello again! Sorry for the long silence

This seems to be an example of the problem described in #4149, so we're going to close this out just to consolidate the discussion over there.

@ghost
Copy link

ghost commented Sep 22, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Sep 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
config enhancement v0.11 Issues (primarily bugs) reported against v0.11 releases v0.12 Issues (primarily bugs) reported against v0.12 releases
Projects
None yet
Development

No branches or pull requests

5 participants