terraform-provider-google icon indicating copy to clipboard operation
terraform-provider-google copied to clipboard

terraform plan errors when the provider's default project is unknown during plan

Open queeno opened this issue 1 year ago • 8 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

terraform plan -v
Terraform v1.6.0
on darwin_arm64
+ provider registry.terraform.io/hashicorp/google v5.0.0
+ provider registry.terraform.io/hashicorp/random v3.5.1

Affected Resource(s)

  • google_service_account

Terraform Configuration Files

provider "google" {}

provider "google" {
  alias = "test_project"
  project = google_project.test.project_id
}

resource "random_string" "string" {
  length = "6"
}

resource "google_project" "test" {
  name = "my-test-project"
  project_id = "my-test-project-${random_string.string.result}"
  org_id = "123456789"
}

resource "google_service_account" "test" {
  provider = google.test_project
  display_name = "test-service-account"
  account_id = "test-service-account"
}

Debug Output

TF plan output

Expected Behavior

A plan should have been created.

Actual Behavior

The following error is observed:

╷
│ Error: 1 error occurred:
│       * Failed to retrieve project, pid: , err: project: required field is not set
│
│
│
│   with google_service_account.test,
│   on project.tf line 26, in resource "google_service_account" "test":
│   26: resource "google_service_account" "test" {
│

Steps to Reproduce

  1. terraform plan

queeno avatar Oct 05 '23 16:10 queeno