I'm trying to run my AWS Lambda functions locally in a NodeJS environment with serverless invoke local [...] (as per https://www.serverless.com/framework/docs/providers/aws/cli-reference/invoke-local).
I keep getting error messages from appsync/graphql/apollo, stating: "Error: Network error: Response not successful: Received status code 403"
While debugging I found that I get the following:
appsync.js:
const AWS = require("aws-sdk");
console.log(AWS.config.credentials); // returns null
If I try to run the same file with node appsync.js then instead of null, AWS.config.credentials returns a valid credentials object (taken from my local .aws/credentials file.
So everything is where it should be, the only problem seems to be with the serverless invoke local ... function not allowing my aws-sdk package to access my .aws/credentials file.
How do I get aws-sdk to set AWS.config.credentials?