What is @aws-sdk/middleware-sdk-sts?
@aws-sdk/middleware-sdk-sts is a middleware package for the AWS SDK for JavaScript. It provides functionality to interact with AWS Security Token Service (STS), which allows you to request temporary, limited-privilege credentials for AWS Identity and Access Management (IAM) users or federated users.
What are @aws-sdk/middleware-sdk-sts's main functionalities?
AssumeRole
This feature allows you to assume a role and obtain temporary security credentials. The code sample demonstrates how to use the AssumeRoleCommand to assume a role and log the temporary credentials.
const { STSClient, AssumeRoleCommand } = require('@aws-sdk/client-sts');
const client = new STSClient({ region: 'us-west-2' });
const command = new AssumeRoleCommand({
RoleArn: 'arn:aws:iam::123456789012:role/demo',
RoleSessionName: 'demoSession'
});
client.send(command).then((data) => {
console.log(data.Credentials);
}).catch((error) => {
console.error(error);
});
GetCallerIdentity
This feature allows you to retrieve details about the IAM user or role whose credentials are used to call the operation. The code sample demonstrates how to use the GetCallerIdentityCommand to get the caller's identity.
const { STSClient, GetCallerIdentityCommand } = require('@aws-sdk/client-sts');
const client = new STSClient({ region: 'us-west-2' });
const command = new GetCallerIdentityCommand({});
client.send(command).then((data) => {
console.log(data);
}).catch((error) => {
console.error(error);
});
Other packages similar to @aws-sdk/middleware-sdk-sts
@aws-sdk/client-iam
@aws-sdk/client-iam is another AWS SDK package that provides functionalities to interact with AWS Identity and Access Management (IAM). While @aws-sdk/middleware-sdk-sts focuses on temporary security credentials, @aws-sdk/client-iam provides broader IAM functionalities such as managing users, groups, roles, and policies.
aws-sdk
aws-sdk is the official AWS SDK for JavaScript, which includes a wide range of AWS services, including STS. It provides a more comprehensive set of features compared to @aws-sdk/middleware-sdk-sts, which is specialized for STS-related operations.