forked from k1LoW/serverless-s3-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getAwsOptions.js
25 lines (23 loc) · 990 Bytes
/
getAwsOptions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function getAwsOptions(provider) {
if (provider.cachedCredentials && typeof(provider.cachedCredentials.accessKeyId) != 'undefined'
&& typeof(provider.cachedCredentials.secretAccessKey) != 'undefined'
&& typeof(provider.cachedCredentials.sessionToken) != 'undefined') {
return {
// Temporarily disabled the below below because Serverless framework is not interpolating ${env:foo}
// in provider.credentials.region or provider.cachedCredentials.region
// region: provider.cachedCredentials.region,
region: provider.getRegion(),
credentials: {
accessKeyId: provider.cachedCredentials.accessKeyId,
secretAccessKey: provider.cachedCredentials.secretAccessKey,
sessionToken: provider.cachedCredentials.sessionToken,
}
}
} else {
return {
region: provider.getRegion() || provider.getCredentials().region,
credentials: provider.getCredentials().credentials
}
}
}
module.exports = getAwsOptions