Search code examples
google-cloud-functionsgcloudgoogle-cloud-tasks

Cloud Task Location and Cloud Function Locations are Different


When I first set up my Cloud Tasks I never choose a location, I let Google do it based off of my project settings. When I run $ gcloud functions list all of my functions are in us-central1

enter image description here

When I go to the Cloud Task console to check on my queue the Location is us-east1 and when I run $ gcloud app describe I get locationId: us-east1

enter image description here

Why are the Locations different and will this cause any issues with my project?

Im my index.js file I use the following to set my queuePath:

const project = JSON.parse(process.env.FIREBASE_CONFIG!).projectId;
const location = 'us-east1';
const queue = 'ttl-task';

Solution

  • In most (?) cases, Console or gcloud require the user to provide a location if it's required for a deployment. There may be exceptions; Firestore databases are colocated with App Engine apps and, App Engine apps once located in a project are singletons and can't be moved, for example.

    gcloud has an accompanying config command that sets defaults for subsequent gcloud commands. This can catch the (un)wary and I recommend not setting defaults (beside the auth account) and always e.g. --region=... or --location=... etc when using gcloud; this is more clearly intentional particularly in scripts (although remains imperfect).

    You likely either chose the Console default or had a region or location default set when you deployed the Cloud Tasks.

    Generally, you want to minimize network traffic "distance" because it's always faster to send network traffic within one e.g. location than across locations because these are physically distant and even light would take non-zero time to transit the space.