-
Notifications
You must be signed in to change notification settings - Fork 615
Default AWS credentials provider chain resolution changed in v3 for EC2MetadataCredentials/ECSCredentials - readFile calls more frequent #2027
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
Comments
we are seeing the same thing on our tests. here is an example datadog trace we are making two dynamo db calls. and it's reading the filesystem twice for each request 1 to /root/.aws/config even though we have environment variables for the access and secret key. Due to #1808, we used this as a workaround to avoid downgrading to v2. |
i ran another test, and we are definitely seeing a performance hit here.
Here is another view so we are seeing an overall latency increase in app. Haven't figured out the http increase yet |
We're seeing the performance penalty caused by two We're configuring the client with static credentials (see below), so I'd expect no other credentials provider resolution is even done, as it's not needed:
Any idea what's going on? Version 3.11.0 |
According to #1808 (comment)
I can't be sure - I'm just guessing without having seen any feedback from maintainers so far. It seems like #2148 is still open and this issue I reported may be a symptom of that? My use case has some things in common with the other tickets such as AWS_PROFILE but I'm uncertain if the framework I'm using is using source_profile (but the applications using the framework does depend on sts) I see PR #2179 is linked to that and open I haven't had the time to get a stack trace for this because it's running in fargate and I haven't had much free time. It'd be useful if someone encountering the issue could provide:
const fs = require('fs');
const originalReadFile = fs.readFile;
fs.readFile = (...args) => {
console.log(`file=${args[0]} stack=${new Error().stack}`);
originalReadFile(...args);
};
fs.readFile('node.js', (err, data) => console.log(`err=${err} data=${data}`)); |
@TysonAndre here you go
Used
|
@TysonAndre @matej-prokop Thank you for sharing the detailed stack trace. I think I have an idea where these |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Describe the bug
After upgrading an ECS(Fargate) from aws-sdk-js-v2 to v3, I started seeing a lot more calls to readFile being performed (in newrelic, per transaction) despite no environment variables changing.
The usage is effectively
const { DynamoDB } = require('@aws-sdk/client-dynamodb'); /*... */; const db = new DynamoDB({region: 'us-east-1'});
, and the instance of DynamoDB is reusedI suspect this is because the existence of the AWS_PROFILE environment variable changes the credentials provider chain that is used - This was not the case in v2.(I still haven't confirmed it)
new AWS.SecretsManager({endpoint, region})
before other calls to aws but that doesn't seem relevantEDIT: I wonder if v3 is parsing the wrong expiry somehow - e.g. aws-sdk v2's node_modules/aws-sdk/lib/credentials/remote_credentials.js hadexpireTime: new Date(credData.expiration || credData.Expiration)
. I also see the ini files checked before remote credentialsI don't see any documentation of why the decision was made to have ENV_PROFILE('AWS_PROFILE') be used this way in the file itself. It seems to have been done this way in ecb884b or earlier and kept that way(EDIT: Probably not the cause of this issue - AWS_PROFILE is not included in https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-config.html and the aws console does not show it among additional environment variables)V3 credential chain is conditional
V2 Credential Chain has no conditions
Your environment
SDK version number
@aws-sdk/[email protected]
(3.4.1 for everything else)Is the issue in the browser/Node.js/ReactNative?
Nodejs
Details of the browser/Node.js/ReactNative version
node -v
is roughlyv14.15.5
(using Docker node:14)Steps to reproduce
TODO
Observed behavior
Overall performance is worse, requests take longer to process after upgrading from v2 to v3. Calls to Filesystem.readFile are very frequent, probably trying to look up aws credentials in a missing file or failing to cache them.
Expected behavior
No performance impact.
If the environment variable AWS_PROFILE is set, this should not prevent the ECS/EC2 metadata service from being used if the required environment variables are available (i.e.
chain(fromIni(init), fromProcess(init))
currently does not contain fromRemoteProvider)Screenshots
(A spike in calls to readFile(green) was seen when upgrading to aws-sdk-js-v3 and went away after rolling back)
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: