Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@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 2,768,550 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.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.