-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Since Version 2.575.0 - CognitoIdentity.getOpenIdTokenForDeveloperIdentity is too slow #3005
Comments
Hey @khacminh, Thank-you for reaching out to us with your issue. Can you please provide the logs, to do that you can do something like: To do you can do something like following:
|
hi @ajredniwja, here is the log that I got
|
@khacminh, do you get the same output when you run it locally? |
@ajredniwja it's only takes over 1 second when I run it from my PC (with Access Key ID and Secret Access Key provided). On the EC2 machine, I attached an IAM role to the machine instead of providing the access keys. |
Hey @khacminh I was not able to reproduce this, is there any additional context you can provide? |
Hi @ajredniwja , I created a new EC2 machine running Ubuntu 18.04 and run the script with node.js 10.7 and as you said, there is no problem with it. It took only 100ms to get the OpenId Token. Then, I installed docker and run the script inside a container with the image base is mhart/alpine-node:10.7 and it took about 5s to run the script. |
I tried with the base image is the official node:12.16.0-alpine3.11 and met the same problem |
Hi @ajredniwja Any update for this issue? Today, I meet the same issue with |
Hey @khacminh, I believe the SDK didn't made any major updates, this would be how EC2 is handling things, reached out to the service team, will update you once I hear back from the service team. |
For record keeping, possibly same problem for #3223 . |
Hey @khacminh and @wdittmer-mp Can you collect some logs using something like
|
Hi, any news on this? |
Hey @wdittmer-mp sorry for late response, can you try supplying the credentials explicitly so that you don't touch any metadata server, this might not be related to the SDK but how the communication is done with the instance metadata server. Also can you confirm if it is still the case with the latest version of the SDK? |
I can try out the latest version of the SDK yes: I am not sure what you mean with supplying the credentials explicitly? I use the following:
I don't know how to be more explicit 😅 . |
Here is my testing environment:
FROM node:12.16.0-alpine3.11
RUN mkdir -p /opt/app
ARG NODE_ENV=production
ENV NODE_ENV $NODE_ENV
WORKDIR /opt
COPY package.json package-lock.json ./
RUN npm install --only=prod && npm cache clean --force
WORKDIR /opt/app
COPY ./index.js /opt/app
ENV NODE_DEBUG=cluster,net,http,fs,tls,module,timers
CMD [ "node", "index.js" ]
const Aws = require('aws-sdk');
async function getToken(username) {
const cognito = new Aws.CognitoIdentity({ region: process.env.AWS_REGION, logger: console });
const Logins = {
'my-logins': username
};
const result = await cognito.getOpenIdTokenForDeveloperIdentity({
IdentityPoolId: process.env.IDENTITY_POOL_ID,
Logins,
TokenDuration: 20,
}).promise();
return result.Token;
}
console.log('================= Start ====================');
getToken('test-username').then(() => {
console.log('================= Done ====================');
process.exit(0);
});
Comparing 2.574 and 2.575 logs, the following maybe the one that make the difference |
Hi @ajredniwja, can you share if investigation is still in progress, something has been found or if you require additional info? |
Apologies, I lost track for this issue, I was not able to find any core root cause for it, reaching out to the service team for help, will update you once I hear back from them. |
Hi, is there any news on this? |
I reached out to the service team, awaited reply from them as the SDK doesn't do anything significantly differently between those versions that could affect this. |
Hey @khacminh, @wdittmer-mp, @azimiester Can you guys try to add the following to your code:
If that doesn't work can you please provide impacted instance id and the time period? |
This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing. |
Hi @ajredniwja , const Aws = require('aws-sdk');
Aws.MetadataService.disableFetchToken = true;
async function getToken(username) {
const cognito = new Aws.CognitoIdentity({ region: process.env.AWS_REGION, logger: console });
const Logins = {
'my-logins': username
};
const result = await cognito.getOpenIdTokenForDeveloperIdentity({
IdentityPoolId: process.env.IDENTITY_POOL_ID,
Logins,
TokenDuration: 20,
}).promise();
return result.Token;
}
console.log('================= Start ====================');
getToken('test-username').then(() => {
console.log('================= Done ====================');
process.exit(0);
});
I also tried with the aws-sdk version 2.733 and node:12.18.3-alpine3.12, the same result received |
Hi @ajredniwja,
The instance-id should be: i-0bd45f49e548fc04b The instance will most likely be destroyed tonight to save cost for the test environment. Kind regards, |
This appears to be related to IMDSv2 being the default starting with I can reproduce this issue by executing The reason why IMDSv2 does not work from inside a Docker container is explained here: https://stackoverflow.com/a/62326320/13124514 I've also noticed that setting So it seems there are two issues at play:
EDIT: This is probably unsupported, but it works: |
Hi @ajredniwja, I tried @mhassan1 workaround and it does solve the problem. Could you please take a look at @mhassan1 explanation. If it makes sense to you, please escalate the issue as bug. |
I followed the discussion/links from the stackoverflow of @mhassan1 (thanks!) @chartrand22 also talks about the IMDSv2 in #3024 |
I had the same issue happen in the last two weeks. I finally found that I can run this line before calling into AWS resources and it has resolved my issue. This is for sure a hack, but gets past my issue for now.
Keep in mind, this only works in raw javascript, the Typescript definition does not expose access to this property. |
I ran into the same issue: calling s3.getObject() on a 33 byte file from within a docker container on an ec2 instance takes about 5 seconds using node aws-sdk v 2.826.0. Disabling the fetch token resolved the issue. I reverted back to aws-sdk v2.574.0 and getObject() was as fast as expected without having to disable the fetch token. |
I was having the same issue when upgrading from 2.574.0 to 2.575.0, the S3 upload response time went from 200 ms to 4 seconds. Setting the |
Hello, |
Hello, any updates here? Current version: |
Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue. |
Confirm by changing [ ] to [x] below to ensure that it's a bug:
Describe the bug
Is the issue in the browser/Node.js?
Node.js
If on Node.js, are you running this on AWS Lambda?
No
Details of the Node.js version
v10.7
SDK version number
v2.585.0
To Reproduce (observed behavior)
Today, I updated
aws-sdk
on my project from version2.555.0
to the latest version2.585.0
. Then, I figured out that the function:cognito.getOpenIdTokenForDeveloperIdentity
run longer than expected.200-300ms
to get the result4-5s
to get the resultThe following is the code snippet that I use and the the application is running on a EC2 machine.
UPDATE 1
My buddy find out that the problem occurred since version
2.575.0
UPDATE 2 (05 Feb 2020)
The text was updated successfully, but these errors were encountered: