My handler named taskToFireOff has allUsers
deleted, the Cloud Tasks Enqueuer
principal's name is set to the ServiceAccountEmail
, and its role is set to Invoker
(not shown)
When a post is created, I use .onCreate
to create a task. The task is created but the function that the http request is connected to never fires. I looked here https://console.cloud.google.com/cloudtasks/queue/ and see that there are 2 tasks (I tried twice) just sitting there.
When I go to the Cloud Task page in the console > click the task > Tasks > Method / URL
, it says
POST https://us-east1-myProjectId.cloudfunctions.net/taskToFireOff
But when I go to the task > Logs > View > Suggested > Query Details it says
New error group seen in onCreateData: Error: 3 INVALID_ARGUMENT: Any resource that needs App Engine can only be created/updated in the App Engine region. Location must equal us-east1 because the App
It's an odd error because the above url begins with us-east1 and in my index.js file I set the location using us-east1
exports.onCreateData = functions.database.ref('/posts/{postId}').onCreate(async (snapshot, context) => {
const payload = {"postId": context.params.postId};
const project = JSON.parse(process.env.FIREBASE_CONFIG!).projectId;
const location = 'us-east1';
const queue = 'ttl-task';
const serviceAccountEmail = '[email protected]';
const queuePath = tasksClient.queuePath(project, location, queue);
const url = `https://${location}-${project}.cloudfunctions.net/taskToFireOff`
const task = {
httpRequest: {
httpMethod: 'POST',
url,
oidcToken: {
serviceAccountEmail
},
body: Buffer.from(JSON.stringify(payload)).toString('base64'), // JSON.parse(JSON.stringify(payloadData));
headers: {
'Content-Type': 'application/json',
},
},
scheduleTime: {
seconds: // ...
}
}
const [response] = await tasksClient.createTask({ parent: queuePath, task });
// ...
});
exports.taskToFireOff = functions.https.onRequest((request, response) => {
// ...
});
Also while inside the console, when I click the Task itself and look at the payload, all the correct information is there.
When I created my RealTimeDatabase I was given us-central1
But when I created my Storage bucket, I selected us-east1
. At the bottom of Firestore Database it says
When I enter $ gcloud app describe
it says that the locationId is us-east1
Could the problem be that the Cloud Task is in us-east1
but the Cloud Functions are in us-central1
?
Running $ gcloud functions list
lists all of my Cloud Functions in the us-central1
region
Btw, I created another project just to see the selection that I'm given when creating a Storage bucket. For Storage, there isn't a way to select us-central1. There is a default Multi-region nam5(us-central
) but there isn't a specific region for us-central1
. I selected us-east1
because I'm in NY.