Skip to content

Instantly share code, notes, and snippets.

@thomasmichaelwallace
Last active March 25, 2019 08:47
Show Gist options
  • Save thomasmichaelwallace/a59601b2f387baacd40fe303411b7a62 to your computer and use it in GitHub Desktop.
Save thomasmichaelwallace/a59601b2f387baacd40fe303411b7a62 to your computer and use it in GitHub Desktop.
Http options timeouts for lambda function
import AWS from 'aws-sdk';
const s3 = new AWS.S3({
httpOptions: {
  connectTimeout: 2 * 1000, // time succeed in starting the call
  timeout: 5 * 1000, // time to wait for a response
  // the aws-sdk defaults to automatically retrying if either of these limits are met.
  },
});
// use S3 happily!
const ddb = new AWS.DynamoDB.DocumentClient({
// DocumentClient needs a nested service configuration:
service: new aws.DynamoDB({
httpOptions: { connectTimeout: 2000, timeout: 5000 },
}),
});
// use DynamoDB through the DocumentClient interface happily!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment