awsRegion does not override awsOptions.region
Opened this issue · 0 comments
Nalgmann commented
Issue type: Bug
Hi.
According with docs, awsOptions
are overridden by any other if specified. This is not true in case of awsRegion
.
This is why:
index.js, lines 42-55
:
var config = {};
if (awsAccessKeyId && awsSecretKey && awsRegion) {
config = { accessKeyId: awsAccessKeyId, secretAccessKey: awsSecretKey, region: awsRegion };
} else if (awsRegion && !awsAccessKeyId && !awsSecretKey) {
// Amazon SDK will automatically pull access credentials
// from IAM Role when running on EC2 but region still
// needs to be configured
config = { region: awsRegion };
}
if (options.awsOptions) {
config = assign(config, options.awsOptions);
}
In line 54
occurs everything. According to lodash: Subsequent sources overwrite property assignments of previous sources.
This may cause confusion using the package.
A possible solution may be assigning options.awsOptions
before awsAccessKeyId
, awsSecretKey
and awsRegion
. When assigning this three properties use assign()