What is @smithy/credential-provider-imds?
The @smithy/credential-provider-imds package is designed to retrieve AWS credentials from the EC2 Instance Metadata Service (IMDS). It allows applications running on EC2 instances to securely obtain temporary credentials without needing to hard-code them. This is particularly useful for managing access to AWS services in a secure and scalable way.
Fetching credentials from IMDS
This feature allows the retrieval of AWS credentials from the EC2 Instance Metadata Service. The provided code sample demonstrates how to asynchronously fetch these credentials using the fromInstanceMetadata function.
const { fromInstanceMetadata } = require('@smithy/credential-provider-imds');
async function getCredentials() {
const credentials = await fromInstanceMetadata();
return credentials;
}