Skip to content

Commit

Permalink
Support for credentials.sessionToken, and dynamically setting other A…
Browse files Browse the repository at this point in the history
…WS SDK specific configurations
  • Loading branch information
dxdc committed Oct 30, 2023
1 parent a4bb740 commit ec94708
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
20 changes: 14 additions & 6 deletions dist/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@ const AWS_CONFIG_TEST = {
region: 'us-east-1',
};

function initConfig(config) {
function initConfig({ region, accessKey, secretKey, sessionToken, ...rest }) {
AWS.config = new AWS.Config();

const credentials = {
accessKeyId: accessKey,
secretAccessKey: secretKey,
};

if (sessionToken) {
credentials.sessionToken = sessionToken;
}

AWS.config.update({
region: config.region,
region,
sslEnabled: true,
credentials: {
accessKeyId: config.accessKey,
secretAccessKey: config.secretKey,
},
credentials,
...rest,
});
}
20 changes: 14 additions & 6 deletions src/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@ const AWS_CONFIG_TEST = {
region: 'us-east-1',
};

function initConfig(config) {
function initConfig({ region, accessKey, secretKey, sessionToken, ...rest }) {
AWS.config = new AWS.Config();

const credentials = {
accessKeyId: accessKey,
secretAccessKey: secretKey,
};

if (sessionToken) {
credentials.sessionToken = sessionToken;
}

AWS.config.update({
region: config.region,
region,
sslEnabled: true,
credentials: {
accessKeyId: config.accessKey,
secretAccessKey: config.secretKey,
},
credentials,
...rest,
});
}

0 comments on commit ec94708

Please sign in to comment.