I'm building a Vue SPA, that connects with some AWS services in the backend, and I need to globally configure the AWS SDK using a region and some credentials provided via STS. The problem is that after I call AWS.config.update inside my getCredentials submodule, the configuration doesn't update those parameters for subsequent imports of the SDK at different submodules.
The code looks like this:
getCredentials:
import * as AWS from 'aws-sdk/global';
AWS.config.update({
region: 'aws-region',
credentials: new myCredentialsObject(),
})
otherSubmodule:
const AWS = require('aws-skd');
const lambda = new AWS.Lamda();
lambda.invoke(params, callback);
The error I get back in the callback is:
ConfigError: Missing region in config
at Request.VALIDATE_REGION (event_listeners.js?b7ab:94)
at Request.callListeners (sequential_executor.js?78b0:106)
at callNextListener (sequential_executor.js?78b0:96)
at eval (event_listeners.js?b7ab:86)
at finish (config.js?6e76:386)
at Config.getCredentials (config.js?6e76:431)
at Request.VALIDATE_CREDENTIALS (event_listeners.js?b7ab:81)
at Request.callListeners (sequential_executor.js?78b0:102)
at Request.emit (sequential_executor.js?78b0:78)
at Request.emit (request.js?87f7:688)