jest-dynalite
jest-dynalite copied to clipboard
AWS SDK error wrapper for Error: getaddrinfo ENOTFOUND
Hi there,
I'm receiving the following error when running jest-dynalite
AWS SDK error wrapper for Error: getaddrinfo ENOTFOUND sts.local.amazonaws.com
at asSdkError (../../node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/middleware-retry/dist-cjs/StandardRetryStrategy.js:88:12)
at StandardRetryStrategy.retry (../../node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/middleware-retry/dist-cjs/StandardRetryStrategy.js:61:29)
at ../../node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:6:22
at Object.roleAssumer (../../node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/client-sts/dist-cjs/defaultStsRoleAssumers.js:34:33)
at coalesceProvider (../../node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/property-provider/dist-cjs/memoize.js:14:24)
at SignatureV4.credentialProvider (../../node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/property-provider/dist-cjs/memoize.js:33:24)
at SignatureV4.signRequest (../../node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/signature-v4/dist-cjs/SignatureV4.js:84:29)
at ../../node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/middleware-signing/dist-cjs/middleware.js:13:18
at StandardRetryStrategy.retry (../../node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/middleware-retry/dist-cjs/StandardRetryStrategy.js:51:46)
I'm using typescript and the advanced setup
I'm creating my dynamodb document client using the following snippet inside my test suite
const buildDocumentClient = () => getClient({
endpoint: `http://${process.env['MOCK_DYNAMODB_ENDPOINT']}`,
tls: false,
region: "local",
credentials: {
accessKeyId: "dummy",
secretAccessKey: "dummy"
}
});
I'm currently using the following versions:
- @aws-sdk/client-dynamodb: 3.58.0
- @aws-sdk/lib-dynamodb: 3.58.0
- jest-dynalite: 3.4.4
I've tried the simple setup and using a js setup file with no luck.
What does your getClient
function do?
It seems the region: 'local'
param is being used in the host amazon is trying to access
AWS SDK error wrapper for Error: getaddrinfo ENOTFOUND sts.local.amazonaws.com
export function getClient(configuration: DynamoDBClientConfig = {}) {
const client = new DynamoDBClient(configuration);
return DynamoDBDocumentClient.from(client, {marshallOptions: {removeUndefinedValues: true}});
}
Just following the docs https://github.com/freshollie/jest-dynalite#update-your-sourcecode
Could you try using a valid region?
For anyone who faced the same issue: this happens if you have a valid AWS_PROFILE
environmental variable. Setting process.env.AWS_PROFILE = ''
somewhere in your jest.setup.ts/js
file resolves this behaviour.
Oh I wonder if I should delete AWS_PROFILE
to nothing as part of this library, it feels like it's unrelated?
Oh I wonder if I should delete
AWS_PROFILE
to nothing as part of this library, it feels like it's unrelated?
Well, if you ask me, then probably it's a good idea to do a backup of the original value of process.env.AWS_PROFILE
, delete it before the tests, and restore it afterwards. Or just delete it altogether, either way works.
I'm going to delete and restore AWS_PROFILE
when I run any commands against the DB in the library. At least that way the error won't come from within the library but from your own tests if you use still have AWS_PROFILE
set