@cloud-copilot/iam-collect
Version:
Collect IAM information from AWS Accounts
25 lines • 915 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTokenInfo = getTokenInfo;
const client_sts_1 = require("@aws-sdk/client-sts");
/**
* Get the AWS account ID and partition from the provided credentials.
*
* @param credentials The AWS credentials to use for the request.
* @returns An object containing the AWS account ID and partition for the provided credentials.
*/
async function getTokenInfo(credentials) {
const stsClient = new client_sts_1.STSClient({ credentials });
const command = new client_sts_1.GetCallerIdentityCommand({});
const response = await stsClient.send(command);
const accountId = response.Account;
const arn = response.Arn;
const arnParts = arn.split(':');
const partition = arnParts[1];
return {
accountId: accountId,
partition: partition,
arn: arn
};
}
//# sourceMappingURL=tokens.js.map