Reputation: 1
I'm working on an AWS Lambda function using Node.js 12.x. I have the accountId that I pulled from the event.requestContext
. Is there a way how to get the name of the account using the accountId inside the lambda function?
Upvotes: 0
Views: 1880
Reputation: 9655
You can actually list the account aliases using api call ListAccountAliases. The corresponding example in from the documentaiton
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'REGION'});
// Create the IAM service object
var iam = new AWS.IAM({apiVersion: '2010-05-08'});
iam.listAccountAliases({MaxItems: 10}, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data);
}
});
Upvotes: 2