0

我正在使用 Node.js 12.x 开发 AWS Lambda 函数。我有从event.requestContext. 有没有办法使用 lambda 函数中的 accountId 获取帐户名称?

4

1 回答 1

2

您实际上可以使用 API 调用ListAccountAliases列出帐户别名。文档中的相应示例

        // 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);
    }
    });
于 2021-01-04T17:45:48.293 回答