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

google_compute_region_network_endpoint_group - Error: project: required field is not set #10016

Closed
andrewmackett opened this issue Sep 6, 2021 · 6 comments
Assignees
Labels

Comments

@andrewmackett
Copy link

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 -v
Terraform v1.0.6
on darwin_amd64
+ provider registry.terraform.io/hashicorp/google v3.82.0
+ provider registry.terraform.io/hashicorp/google-beta v3.82.0

Affected Resource(s)

  • google_compute_region_network_endpoint_group

Terraform Configuration Files

// https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_region_network_endpoint_group#example-usage---region-network-endpoint-group-cloudrun

// Cloud Run Example
resource "google_compute_region_network_endpoint_group" "cloudrun_neg" {
  name                  = "cloudrun-neg"
  network_endpoint_type = "SERVERLESS"
  region                = "us-central1"
  cloud_run {
    service = google_cloud_run_service.cloudrun_neg.name
  }
}

resource "google_cloud_run_service" "cloudrun_neg" {
  name     = "cloudrun-neg"
  location = "us-central1"

  template {
    spec {
      containers {
        image = "us-docker.pkg.dev/cloudrun/container/hello"
      }
    }
  }

  traffic {
    percent         = 100
    latest_revision = true
  }
}

Debug Output

GitHub Gist containing the debug output.

Panic Output

N/A

Expected Behavior

  • The google_compute_region_network_endpoint_group resource should be created without a project being defined (the documentation for this resource says that the project field is optional).
  • The resource should also be created if a value for the project field is defined.

Actual Behavior

Terraform returns an error:

Error: project: required field is not set
│ 
│   with google_cloud_run_service.cloudrun_neg,
│   on main.tf line 12, in resource "google_cloud_run_service" "cloudrun_neg":
│   12: resource "google_cloud_run_service" "cloudrun_neg" {

This error is produced even when a project ID value is defined in the google_compute_region_network_endpoint_group resource.

Steps to Reproduce

  1. terraform apply will produce the error
  2. Add project = "PROJECT_ID" line to the google_compute_region_network_endpoint_group resource (with a valid project ID)
  3. terraform apply will produce the same error

Important Factoids

N/A

References

@andrewmackett andrewmackett changed the title google_compute_region_network_endpoint_group - Error: project: required field is not set google_compute_region_network_endpoint_group - Error: project: required field is not set Sep 6, 2021
@edwardmedia edwardmedia self-assigned this Sep 6, 2021
@edwardmedia
Copy link
Contributor

edwardmedia commented Sep 6, 2021

@andrewmackett did you provide project in the provider block or have the environment variable GOOGLE_PROJECT? It is optional if you have either of one available. Please review below doc that might be helpful.

https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/getting_started#configuring-the-provider

@andrewmackett
Copy link
Author

@edwardmedia yes, after hitting this issue I added the project to the google provider block which is a successful work around.

However I believe there's still an issue here because setting a project value on the google_compute_region_network_endpoint_group resource has no effect and it shouldn't be necessary to set the project in the provider if the project is already defined on the resource.

@edwardmedia
Copy link
Contributor

@andrewmackett it works fine with me by adding the project attribute in the resource. Can you provide the exact config (mentioned here) that does not work for you along with the debug log?

@edwardmedia
Copy link
Contributor

@andrewmackett is this still an issue?

@edwardmedia
Copy link
Contributor

@andrewmackett closing assuming it is no longer an issue

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants