Target localhost from GCP Cloud Tasks

Viewed 491

I am working with GCP Cloud Tasks API on localhost at the moment. I am able to enqueue tasks in Google from localhost by injecting my default credentials.

I am passing a localhost URL as the callback when the task is to execute. Is this possible to do for development?

Or does the callback URL have to be a hosted endpoint?

1 Answers

See Cloud Tasks documentation:

With this release of HTTP Targets, Cloud Tasks handlers can now be run on any HTTP endpoint with a public IP address, such as Cloud Functions, Cloud Run, GKE, Compute Engine, or even an on-prem web server. Your tasks can be executed on any of these services in a reliable, configurable fashion.

Meaning, it's currently not possible to pass a localhost URL as a callback when executing tasks. For development purposes, Cloud Tasks doesn't have an official emulator yet but a feature request already exists. Please make sure to "star" it so it can gain traction.

As an alternative to your objective, here's a few third-party Cloud Task emulators so you can test locally. Check out the following links:

Related