Ember CLI Deploy S3 Plugin
ember-cli-deploy-s3 is an `ember-cli-deploy` plugin designed to upload static assets, such as JavaScript, CSS, images, and the `index.html` file, to an Amazon S3 bucket as part of an Ember CLI application's deployment pipeline. The current stable version is 5.0.1, with releases typically occurring as needed to address bugs, incorporate new features, or handle breaking changes in its underlying dependencies like the AWS SDK. Its primary differentiator is its seamless integration into the `ember-cli-deploy` ecosystem, providing a standardized way to handle asset deployment to S3 without manual scripting. It leverages the AWS SDK for credential resolution and S3 operations, with version 5.x adopting AWS SDK v3, which introduced significant changes compared to previous versions. Configuration is handled through the `config/deploy.js` file, allowing developers to specify S3 bucket details, access credentials, regions, and file patterns for upload.
Common errors
-
Could not find `S3Client` in `@aws-sdk/client-s3`
cause Attempting to use AWS SDK v2 patterns or an outdated `@aws-sdk/client-s3` package after upgrading to `ember-cli-deploy-s3` v5.0.0. The underlying AWS SDK changed from v2 to v3.fixUpdate your `package.json` and `yarn.lock`/`package-lock.json` to ensure `@aws-sdk/client-s3` (and other related v3 packages) are correctly installed and that any custom S3 interaction code uses the new v3 API. -
Missing required key 'bucket' in params
cause The `bucket` configuration option in `config/deploy.js` for the `s3` plugin is missing or empty.fixEnsure `ENV.s3.bucket` is defined with your S3 bucket name in `config/deploy.js`. -
Access Denied
cause AWS credentials (`accessKeyId`, `secretAccessKey`, `sessionToken` or resolved via profile/environment) are incorrect, missing, or lack the necessary permissions to perform S3 operations on the specified bucket/prefix.fixVerify your AWS `accessKeyId`, `secretAccessKey`, and optionally `sessionToken`. Check the IAM user/role permissions for S3 actions (e.g., `s3:PutObject`, `s3:GetObjectAcl`, `s3:ListBucket`). Ensure the `region` is correctly set and matches your bucket. -
Node.js version x.y.z is not supported
cause Using a Node.js version older than required by `ember-cli-deploy-s3` v4.0.0+.fixUpgrade Node.js to version `14.x || 16.x || 18.x || >= 20.*` to meet the plugin's minimum requirements. -
Cannot read properties of undefined (reading 'upload')
cause Attempting to share a single configuration object between `ember-cli-deploy-s3` and `ember-cli-deploy-s3-index`, leading to conflicting state or unexpected side effects.fixDefine separate, distinct configuration objects for `ENV.s3` and `ENV['s3-index']` in `config/deploy.js`. Do not assign the same object reference to both.
Warnings
- breaking Version 5.0.0 introduced a breaking change by upgrading to AWS SDK v3. This changes how AWS services are initialized and called, moving from a monolithic `aws-sdk` package to modular `@aws-sdk/*` packages. Existing custom S3 client configurations or integrations relying on AWS SDK v2 will break.
- breaking Version 4.0.0 updated node version requirements (to `14.x || 16.x || 18.x || >= 20.*`) and other dependencies. Deployments on older Node.js versions will fail.
- gotcha Sharing a single configuration object between `ember-cli-deploy-s3` and `ember-cli-deploy-s3-index` in `config/deploy.js` will lead to deployment failures due to side effects in how these plugins read their configuration.
- gotcha If `accessKeyId` and `secretAccessKey` are not explicitly defined, the plugin relies on the default AWS SDK credential resolution chain (e.g., environment variables, shared credentials file, IAM roles). Misconfiguration or missing credentials in these sources will result in authentication failures during deployment.
- gotcha When using temporary credentials via AWS Security Token Service (STS), `sessionToken` must be provided along with `accessKeyId` and `secretAccessKey`. Failing to provide the `sessionToken` will lead to authentication errors, even if the other credentials are correct. Version 5.0.1 included a fix to ensure the `sessionToken` is correctly passed to AWS credentials.
Install
-
npm install ember-cli-deploy-s3 -
yarn add ember-cli-deploy-s3 -
pnpm add ember-cli-deploy-s3
Imports
- s3 (configuration object)
import { s3Config } from 'ember-cli-deploy-s3';ENV.s3 = { accessKeyId: process.env.AWS_ACCESS_KEY_ID ?? '', secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY ?? '', bucket: 'your-s3-bucket-name', region: 'your-s3-bucket-region' }; - DeployS3Plugin (internal)
const DeployS3Plugin = require('ember-cli-deploy-s3'); // CommonJS import { DeployS3Plugin } from 'ember-cli-deploy-s3'; // Named vs Defaultimport DeployS3Plugin from 'ember-cli-deploy-s3';
- S3Client (internal AWS SDK dependency)
import { S3 } from 'aws-sdk'; // AWS SDK v2 style// The plugin internally uses AWS SDK v3's S3Client. import { S3Client } from '@aws-sdk/client-s3';
Quickstart
ember install ember-cli-deploy-s3
// config/deploy.js
module.exports = function(deployTarget) {
const ENV = {
build: {},
s3: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID ?? 'YOUR_AWS_ACCESS_KEY',
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY ?? 'YOUR_AWS_SECRET_KEY',
bucket: 'your-s3-bucket',
region: 'your-s3-bucket-region'
}
};
if (deployTarget === 'production') {
// Additional production-specific configuration
}
return ENV;
};
// Run the deployment
// ember deploy