Skip to content

Commit cf7696e

Browse files
fix on sts get caller identity
1 parent bdcf4a4 commit cf7696e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

extensions/utils/VaultClientWrapper.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { fromTemporaryCredentials } = require('@aws-sdk/credential-providers');
22
const { errorUtils } = require('arsenal');
3-
const { GetCallerIdentityCommand } = require('@aws-sdk/client-sts');
3+
const { STSClient, GetCallerIdentityCommand } = require('@aws-sdk/client-sts');
44

55
const { authTypeAssumeRole, authTypeNone } = require('../../lib/constants');
66
const VaultClientCache = require('../../lib/clients/VaultClientCache');
@@ -47,8 +47,18 @@ class VaultClientWrapper {
4747
const stsWithCreds = CredentialsManager.resolveExternalFileSync(sts, this.logger);
4848
const endpoint = `${sts.transport || 'https'}://${sts.host}:${sts.port}`;
4949

50+
const stsClient = new STSClient({
51+
endpoint,
52+
region: sts.region || 'us-east-1',
53+
credentials: {
54+
accessKeyId: stsWithCreds.accessKey,
55+
secretAccessKey: stsWithCreds.secretKey,
56+
},
57+
requestHandler: this.stsAgent,
58+
});
59+
5060
const getCallerIdentity = new GetCallerIdentityCommand({});
51-
this._tempCredsPromise = stsWithCreds.send(getCallerIdentity)
61+
this._tempCredsPromise = stsClient.send(getCallerIdentity)
5262
.then(res => {
5363
const roleArn = `arn:aws:iam::${res.Account}:role/${roleName}`;
5464
const roleSessionName = `${this._clientId}`;

0 commit comments

Comments
 (0)