Product
Introducing Ruby Support in Socket
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
@aws-sdk/credential-provider-imds
Advanced tools
AWS credential provider that sources credentials from the EC2 instance metadata service and ECS container metadata service
@aws-sdk/credential-provider-imds is a part of the AWS SDK for JavaScript. It provides a way to retrieve AWS credentials from the Instance Metadata Service (IMDS) on Amazon EC2 instances. This is particularly useful for applications running on EC2 instances that need to interact with other AWS services securely.
Retrieve Credentials from IMDS
This feature allows you to retrieve AWS credentials from the Instance Metadata Service (IMDS) on an EC2 instance. The code sample demonstrates how to use these credentials to make a call to the AWS STS service to get the caller identity.
const { fromInstanceMetadata } = require('@aws-sdk/credential-provider-imds');
const { STSClient, GetCallerIdentityCommand } = require('@aws-sdk/client-sts');
(async () => {
const client = new STSClient({
credentials: fromInstanceMetadata(),
});
const command = new GetCallerIdentityCommand({});
const response = await client.send(command);
console.log(response);
})();
Handle IMDS Timeout
This feature allows you to specify a timeout for the IMDS request. The code sample demonstrates how to set a 1-second timeout for retrieving credentials from IMDS and handle any potential errors.
const { fromInstanceMetadata } = require('@aws-sdk/credential-provider-imds');
const { STSClient, GetCallerIdentityCommand } = require('@aws-sdk/client-sts');
(async () => {
const client = new STSClient({
credentials: fromInstanceMetadata({ timeout: 1000 }), // 1 second timeout
});
const command = new GetCallerIdentityCommand({});
try {
const response = await client.send(command);
console.log(response);
} catch (error) {
console.error('Error retrieving credentials:', error);
}
})();
The 'aws-sdk' package is the previous version of the AWS SDK for JavaScript. It also provides functionality to retrieve credentials from the Instance Metadata Service (IMDS) on EC2 instances. However, the new modular AWS SDK v3, which includes @aws-sdk/credential-provider-imds, offers better performance and smaller bundle sizes.
An internal package
You probably shouldn't, at least directly. Please use @aws-sdk/credential-providers instead.
FAQs
AWS credential provider that sources credentials from the EC2 instance metadata service and ECS container metadata service
The npm package @aws-sdk/credential-provider-imds receives a total of 3,051,706 weekly downloads. As such, @aws-sdk/credential-provider-imds popularity was classified as popular.
We found that @aws-sdk/credential-provider-imds demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.