-
Notifications
You must be signed in to change notification settings - Fork 5
/
aws_access.js
31 lines (28 loc) · 1.19 KB
/
aws_access.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
26
27
28
29
30
31
const core = require('@actions/core');
const akeylessApi = require('./akeyless_api');
const akeyless = require('akeyless');
async function awsLogin(akeylessToken, producerForAwsAccess, apiUrl) {
let api = akeylessApi.api(apiUrl);
return new Promise((resolve, reject) => {
return api.getDynamicSecretValue(akeyless.GetDynamicSecretValue.constructFromObject({
'token': akeylessToken,
'name': producerForAwsAccess,
})).then(awsCredentials => {
const accessKeyId = awsCredentials['access_key_id'];
const secretAccessKey = awsCredentials['secret_access_key'];
const sessionToken = awsCredentials['security_token'];
core.setSecret(accessKeyId);
core.exportVariable('AWS_ACCESS_KEY_ID', accessKeyId);
core.setSecret(secretAccessKey);
core.exportVariable('AWS_SECRET_ACCESS_KEY', secretAccessKey);
if (sessionToken) {
core.setSecret(sessionToken);
core.exportVariable('AWS_SESSION_TOKEN', sessionToken);
}
resolve();
}).catch(error => {
reject(error);
})
});
}
exports.awsLogin = awsLogin;