In Node.js, reuse TCP connections to improve performance by enabling "keep-alive."
Depending on which version your project requires, the installation process differs. Using Modern Version 3 (Recommended)
Automatically detected if your code is running on EC2, Lambda, or ECS. 5. Best Practices aws-sdk npm
Never hardcode your keys. Use the AWS Secrets Manager or environment variables.
import { S3Client, ListBucketsCommand } from "@aws-sdk/client-s3"; const s3Client = new S3Client({ region: "us-east-1" }); const response = await s3Client.send(new ListBucketsCommand({})); console.log(response.Buckets); Use code with caution. Using Legacy Version 2 If you are maintaining an older project: npm install aws-sdk Use code with caution. javascript In Node
You only install the clients you need. For example, to use and DynamoDB : npm install @aws-sdk/client-s3 @aws-sdk/client-dynamodb Use code with caution. Initialization Example: javascript
v3 is written in TypeScript, providing excellent autocomplete and type safety out of the box. Best Practices Never hardcode your keys
One massive package containing every single AWS service. This often leads to bloated deployment sizes (large node_modules ).
AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY . Shared Credentials File: Located at ~/.aws/credentials .