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/pubsub version: 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
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 pathsEnvironment details
Cloud functions12.20yarn 1.18@google-cloud/pubsubversion:2.10Steps to reproduce
Trying to instantiate a pubsub client
Call function where client is used:
Get error
Warning: iam_service.json not found in any of the include pathsAny help would be appreciated! Due to how cloud functions work I can't seem to use the option of passing a
keyFilenamepathNote I did try following this: #1000
but it still throws
IAM error