-
Notifications
You must be signed in to change notification settings - Fork 634
Closed
Labels
bugThis issue is a bug.This issue is a bug.p2This is a standard priority issueThis is a standard priority issueservice-apiThis issue is due to a problem in a service API, not the SDK implementation.This issue is due to a problem in a service API, not the SDK implementation.
Description
Checkboxes for prior research
- I've gone through Developer Guide and API reference
- I've checked AWS Forums and StackOverflow.
- I've searched for previous similar issues and didn't find any solution.
Describe the bug
Using latest version of https://www.npmjs.com/package/@aws-sdk/ec2-metadata-service seems to not work out of the box with NodeJS v18 in an AWS EKS kubernetes cluster running pod with service account associated and valid policy attached.
Regression Issue
- Select this option if this issue appears to be a regression.
SDK version number
@aws-sdk/[email protected]
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
node v18.20.4
Reproduction Steps
# testing the Pod with latest awscli
root@nodetest:/tmp# /usr/local/bin/aws --version
aws-cli/2.21.2 Python/3.12.6 Linux/6.1.112-124.190.amzn2023.x86_64 exe/x86_64.debian.12
root@nodetest:/tmp# /usr/local/bin/aws sts get-caller-identity
{
"UserId": "xxxxx:eks-app-dev-nodetest-23833230-c77c-4398-95a9-c03cc43bf1a7",
"Account": "xxxxx",
"Arn": "arn:aws:sts::xxxxx:assumed-role/eks-app-dev-app-multimediaworker/eks-app-dev-nodetest-23833230-c77c-4398-95a9-c03cc43bf1a7"
}
root@nodetest:/tmp# /usr/local/bin/aws secretsmanager get-secret-value --secret-id xxxxx --output text > output # Works too
Trying getting metadata info via JS module:
root@nodetest:/tmp# npm install @aws-sdk/ec2-metadata-service
added 19 packages, and audited 20 packages in 2s
found 0 vulnerabilities
root@nodetest:/tmp# cat test.js
const main = async () => {
const { MetadataService } = require("@aws-sdk/ec2-metadata-service");
const metadataService = new MetadataService({});
const metadata = await metadataService.request("/latest/meta-data/", {});
console.log(metadata);
}
main();
root@nodetest:/tmp# node test.js
/tmp/node_modules/@aws-sdk/ec2-metadata-service/dist-cjs/index.js:112
throw new Error(`Error making request to the metadata service: ${error}`);
^
Error: Error making request to the metadata service: Error: Request failed with status code 401
at _MetadataService.request (/tmp/node_modules/@aws-sdk/ec2-metadata-service/dist-cjs/index.js:112:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async main (/tmp/test.js:5:22)
Node.js v18.20.4
Observed Behavior
Error when trying to fetch metadata
Expected Behavior
Metadata fetched correctly
Possible Solution
No response
Additional Information/Context
No response
Metadata
Metadata
Assignees
Labels
bugThis issue is a bug.This issue is a bug.p2This is a standard priority issueThis is a standard priority issueservice-apiThis issue is due to a problem in a service API, not the SDK implementation.This issue is due to a problem in a service API, not the SDK implementation.