You're importing the v3 SDK but writing v2 code. v2 IAM clients expose named methods such as getRole
, CreateUser
etc. but v3 requires you to build a 'command' object and then to send
it via the client object. Recommend you read some of the SDK v3 samples.
Here's one such example:
import { GetRoleCommand, IAMClient } from "@aws-sdk/client-iam";
const client = new IAMClient({ region: "us-west-2" });
const getRole = async (RoleName) => {
const command = new GetRoleCommand({ RoleName });
return client.send(command);
};
If you prefer to use the v2 SDK then:
const AWS = require('aws-sdk');
const iam = new AWS.IAM({ region: "us-west-2" });
const getRole = async (RoleName) => {
return iam.getRole({ RoleName }).promise();
};