-
Notifications
You must be signed in to change notification settings - Fork 233
Closed
Labels
api: pubsubIssues related to the googleapis/nodejs-pubsub API.Issues related to the googleapis/nodejs-pubsub API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
ERROR
I get the following error when I try to use the pubsub client. In my cloud function environment calling pubsub nodejs client.
Warning: iam_service.json not found in any of the include paths
Environment details
- OS:
Cloud functions - Node.js version:
12.20 - npm version:
yarn 1.18 @google-cloud/pubsubversion:2.10
Steps to reproduce
Trying to instantiate a pubsub client
/**
* This service account has full access to pubsub on this project.
* I logged all credentials as well and they are correct.
*/
const sa = functions.config().pubsub.key;
const pubsubClient = new PubSub({
projectId: sa.project_id,
credentials: sa, // this is the service account json file (also tried only as { client_email, private_key } same error
});Call function where client is used:
export const publishToTopic = async (details: { topic: string; body: any }) => {
try {
const data = JSON.stringify(details.body);
const dataBuffer = Buffer.from(data);
await pubsubClient.topic(details.topic).publish(dataBuffer);
return;
} catch (error) {
console.error(JSON.stringify(error));
}
};Get error Warning: iam_service.json not found in any of the include paths
Any help would be appreciated! Due to how cloud functions work I can't seem to use the option of passing a keyFilename path
Note I did try following this: #1000
but it still throws IAM error
Metadata
Metadata
Assignees
Labels
api: pubsubIssues related to the googleapis/nodejs-pubsub API.Issues related to the googleapis/nodejs-pubsub API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.