presidium 0.29.11 → 0.29.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AwsCredentials.js +11 -0
- package/AwsCredentials.test.js +18 -0
- package/package.json +1 -1
package/AwsCredentials.js
CHANGED
|
@@ -24,6 +24,17 @@ const pathResolve = require('./internal/pathResolve')
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
const AwsCredentials = async function (options = {}) {
|
|
27
|
+
if (process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY) {
|
|
28
|
+
const awsCreds = {
|
|
29
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
30
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
31
|
+
}
|
|
32
|
+
if (process.env.AWS_REGION) {
|
|
33
|
+
awsCreds.region = process.env.AWS_REGION
|
|
34
|
+
}
|
|
35
|
+
return awsCreds
|
|
36
|
+
}
|
|
37
|
+
|
|
27
38
|
const profile = (
|
|
28
39
|
typeof options == 'string' ? options : options.profile
|
|
29
40
|
) ?? 'default'
|
package/AwsCredentials.test.js
CHANGED
|
@@ -35,6 +35,24 @@ aws_secret_access_key = FFF
|
|
|
35
35
|
assert.equal(awsCreds.secretAccessKey, 'FFF')
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
{
|
|
39
|
+
process.env.AWS_ACCESS_KEY_ID = 'AA2'
|
|
40
|
+
process.env.AWS_SECRET_ACCESS_KEY = 'FF2'
|
|
41
|
+
const awsCreds = await AwsCredentials()
|
|
42
|
+
assert.equal(awsCreds.accessKeyId, 'AA2')
|
|
43
|
+
assert.equal(awsCreds.secretAccessKey, 'FF2')
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
{
|
|
47
|
+
process.env.AWS_ACCESS_KEY_ID = 'AA2'
|
|
48
|
+
process.env.AWS_SECRET_ACCESS_KEY = 'FF2'
|
|
49
|
+
process.env.AWS_REGION = 'us-east-2'
|
|
50
|
+
const awsCreds = await AwsCredentials()
|
|
51
|
+
assert.equal(awsCreds.accessKeyId, 'AA2')
|
|
52
|
+
assert.equal(awsCreds.secretAccessKey, 'FF2')
|
|
53
|
+
assert.equal(awsCreds.region, 'us-east-2')
|
|
54
|
+
}
|
|
55
|
+
|
|
38
56
|
await fs.promises.rm(`${__dirname}/../.aws`, { recursive: true })
|
|
39
57
|
}).case()
|
|
40
58
|
|