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

Cannot create an App Engine NEG with default routing #15593

Comments

@javierdialpad
Copy link

javierdialpad commented Aug 22, 2023

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 the 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 the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Terraform Version

Terraform v1.5.5
on darwin_arm64
+ provider registry.terraform.io/hashicorp/google-beta v4.79.0

Description

When creating a serverless NEG pointing to App Engine, there's an option called "Default routing", which targets the App Engine application in general, not any specific service or version. This is useful for defining internal routing rules in the application, using the dispatch.yaml configuration file.

Creating the NEG on the GCP console looks like this:

image


However, it doesn't seem that current Terraform code supports that feature. The resource required to create a NEG is compute_region_network_endpoint_group. The app_engine block inside that resource defines 3 optional arguments: service, version and url_mask. Specifying only one of those voids the intent of default routing, and leaving the block empty is not valid as it generates an API error when trying to create the resource:

google_compute_region_network_endpoint_group.app_engine_neg: Creating...
╷
│ Error: Error creating RegionNetworkEndpointGroup: googleapi: Error 400: Either Cloud Run, App Engine, Cloud Function, or Serverless Deployment must be set., badRequest
│
│   with google_compute_region_network_endpoint_group.app_engine_neg,
│   on main.tf line 7, in resource "google_compute_region_network_endpoint_group" "app_engine_neg":
│    7: resource "google_compute_region_network_endpoint_group" "app_engine_neg" {
│

The above error can be reproduced with the following resource definition:

resource "google_compute_region_network_endpoint_group" "app_engine_neg" {
  provider              = google-beta
  name                  = "appengine-neg"
  network_endpoint_type = "SERVERLESS"
  project               = "test-project"
  region                = "us-central1"
  app_engine {
  }
}

New or Affected Resource(s)

  • google_compute_region_network_endpoint_group

Potential Terraform Configuration

One option to solve this could be to add a new flag inside the app_engine block named "default_routing" or similar, to be explicit about creating an App Engine NEG:

resource "google_compute_region_network_endpoint_group" "app_engine_neg" {
  provider              = google-beta
  name                  = "appengine-neg"
  network_endpoint_type = "SERVERLESS"
  project               = "test-project"
  region                = "us-central1"
  app_engine {
    default_routing = true
  }
}

References

  • #0000

b/312433182

@melinath melinath added this to the Goals milestone Aug 28, 2023
@bbrinegar-champion
Copy link

Also encountered this limitation. The workaround seems to be to create separate NEG and Backend Services per App Engine service and move the routing to the load balancer. Frustrating given how simple it is to use the default routing via the Google Console.

@github-actions github-actions bot added forward/review In review; remove label to forward service/compute-networking-neg labels Nov 11, 2023
@melinath
Copy link
Collaborator

melinath commented Nov 16, 2023

If the issue is that appEngine needs to be an empty object, adding allow_empty_object and making the nested fields optional might get the right behavior.

Possibly relevant context:

@melinath melinath removed the forward/review In review; remove label to forward label Nov 16, 2023
@melinath
Copy link
Collaborator

melinath commented Nov 16, 2023

Double-checked and it's already set up that way, except that it's missing send_empty_value: true as described in #12651 (comment)

I can reproduce this with the following config:

resource "google_compute_region_network_endpoint_group" "appengine_neg" {
  name                  = "tf-test-appengine-negawlekr"
  network_endpoint_type = "SERVERLESS"
  region                = "us-central1"
  app_engine {}
}

@melinath melinath added bug forward/review In review; remove label to forward and removed enhancement forward/review In review; remove label to forward labels Nov 16, 2023
@Cheriit
Copy link

Cheriit commented Feb 14, 2024

Fix is waiting in GoogleCloudPlatform/magic-modules#9980

Copy link

github-actions bot commented Apr 6, 2024

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 Apr 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.