Skip to content

Creation of Endpoints for Cloud Functions causes circular dependency between ESP and Endpoint services #5528

Open
@nikolay-bocharov

Description

@nikolay-bocharov

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 v0.12.20
+ provider.google v3.5.0

Affected Resource(s)

google_cloud_run_service
google_endpoints_service

Terraform Configuration Files

resource "google_cloud_run_service" "run" {
  name = var.name
  location = var.location

  template {
    spec {
      containers {
        image = "gcr.io/endpoints-release/endpoints-runtime-serverless:2"
        env {
          name = "ENDPOINTS_SERVICE_NAME"
          value = google_endpoints_service.openapi_service.service_name
        }
      }
    }
  }
}

resource "google_endpoints_service" "openapi_service" {
  service_name = replace(google_cloud_run_service.run.status[0].url,  "https://", "")
  project = var.project_id
  openapi_config = var.config
}

Debug Output

Panic Output

Expected Behavior

Please note that I do not expect this deployment with circular dependency to work.
But there must be a working scenario for creating Endpoints for Google Function possibly followed different approach or with different API.
Current API seem not to permit such cases.

Actual Behavior

The circular dependency error appears

Steps to Reproduce

  1. terraform apply

Important Factoids

Google Cloud endpoint documentation from here - https://cloud.google.com/endpoints/docs/openapi/get-started-cloud-functions reads the following steps to create Endpoint for Google Function

  1. Create ESP service with Google Run and remember the URL address allocated by Google for this service
  2. Crete Endpoint service (Use that URL address obtained on previous step to build the endpoint openapi config)
  3. Update the ESP service created on step 1 with the name of the Endpoint

But these steps make both resources dependent on each other and inevitably bring to circular dependency error in Terraform.
There must be a working scenario for creating Endpoints for Google Function.

References

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions