SecretsManagerClient looks up credentials using fs.readFile even if credentials are passed when initializing
See original GitHub issueDescribe the bug
Despite creating a new SecretsManagerClient with credentials included in the initialization options, the program uses fs.readFile to grab credentials off-disk. The SecretsManagerClient should be using the provided credentials and thus not use fs.readFile at all.
Your environment
aws/codebuild/standard:4.0 Linux image with npm@7.7.5 and node@12.18.0
SDK version number
@aws-sdk/client-s3@3.13.0
Is the issue in the browser/Node.js/ReactNative?
Node.js
Details of the browser/Node.js/ReactNative version
Paste output of npx envinfo --browsers
or node -v
or react-native -v
v12.18.0
Steps to reproduce
If you create a new SecretsManagerClient like so
new SecretsManagerClient({ region: 'us-west-2', credentials: { accessKeyId: 'myAccessKey', secretAccessKey: 'mySecretKey' } })
and proceed to resolve the Promise, the slurpFile
function from @aws-sdk/shared-ini-file-loader is used to grab credentials off the file system.
Observed behavior
While building a new Webpack project with SecretsManagerClient included therein, Webpack warns that there is “Unsafe builtin usage fs.readFile” pointing to the slurfFile function in @aws-sdk/shared-ini-file-loader/dist/es/index.js:87:17
Expected behavior
fs.readFile should not be invoked at all since credentials are passed to the client during initialization.
Additional context
This might possibly be related to https://github.com/aws/aws-sdk-js-v3/issues/2027
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
I tried initializing the SecretsManagerClient with every configuration option I could find, but the program is still trying to grab my
.aws/config
file…{ apiVersion: '2017-10-17', region: 'us-west-2', credentials: { accessKeyId: getPublic(), secretAccessKey: getPrivate(), expiration: undefined, sessionToken: undefined }, maxAttempts: 10, tls: true, signer: undefined, signingEscapePath: undefined, systemClockOffset: undefined, signingRegion: undefined, retryStrategy: undefined, endpoint: undefined, customUserAgent: undefined, defaultUserAgentProvider: undefined, base64Decoder: undefined, base64Encoder: undefined, bodyLengthChecker: undefined, credentialDefaultProvider: undefined, streamCollector: undefined, disableHostPrefix: undefined, utf8Decoder: undefined, utf8Encoder: undefined, requestHandler: undefined, regionInfoProvider: undefined, serviceId: undefined, logger: undefined, urlParser: undefined, runtime: undefined, sha256: undefined }
This causes Lambda to fail on heavy load: