s3-folder-upload is a Node.js utility designed for efficiently uploading local static file directories to Amazon S3 buckets. The package is currently stable at version `2.3.5`, with minor releases deployed on an as-needed basis to introduce new features, fix bugs, or update dependencies, rather than adhering to a strict release schedule. It utilizes the official AWS SDK internally, ensuring robust and reliable integration with S3 services. Key differentiators include its flexible credential management, allowing configuration via environment variables, direct parameters, or AWS IAM role credentials, and providing granular control over S3 object properties such as `ACL`, `CacheControl`, and `Expires` headers, which can be applied globally or per file. The module also supports optional CloudFront invalidation, streamlining cache updates after deployments. Additionally, it offers a command-line interface (CLI) for quick and programmatic deployments, making it well-suited for integration into CI/CD pipelines or for local development workflows managing static assets.
npm install s3-folder-uploadVerified import paths — ran on the pinned version, not inferred.
Demonstrates uploading a local directory to S3 with explicit credentials and optional configurations, including CloudFront invalidation. Creates dummy files for easy testing.
Update all programmatic calls to `s3FolderUpload` to handle the returned Promise, for example by using `await s3FolderUpload(...)` within an `async` function or `.then().catch()`.
Pass `{ useFoldersForFileTypes: false }` in the options object to upload files directly to the specified `uploadFolder` or bucket root.Establish a clear credential loading strategy. For consistent behavior, consider using IAM role credentials on EC2/ECS or providing credentials exclusively via environment variables for CI/CD, avoiding mixing methods unless strictly necessary.
To enable CloudFront invalidation, ensure you pass an `invalidation` object with `awsDistributionId` and `awsInvalidationPath` to the `s3FolderUpload` function. Without it, CloudFront caches will not be updated.
Ensure `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_REGION` environment variables are correctly set, or pass `accessKeyId`, `secretAccessKey`, `region`, and `bucket` directly in the credentials object, or enable `useIAMRoleCredentials: true` on an EC2 instance with an appropriate IAM role.
Verify that your IAM user or role has a policy attached that grants `s3:PutObject`, `s3:PutObjectAcl`, `s3:ListBucket`, and `s3:GetBucketLocation` permissions for the specified bucket and path. Also check the bucket's own policy.
Double-check that the `directoryName` variable correctly points to an existing local folder containing the static files you wish to upload. Use `path.resolve()` for absolute paths.
Confirm the `bucket` name in your credentials object or environment variables is correct and that the bucket exists in the AWS `region` you've configured.
No dependency data recorded yet.