Ember-cli-s3-sync
Install
npm install ember-cli-s3-sync --save-dev
ember generate config-s3
Authenticating with S3
This addon uses aws-sdk
for communicating with Amazon S3. You can provide authentication credentials in the following ways (listed in order of precedence):
ember deploy:s3 --aws-secret=my-secret --aws-key=my-cool-key
- shared credentials file at ~/.aws/credentials file.
- these shell environment variables:
AWS_ACCESS_KEY_ID
, AWS_SECRET_ACCESS_KEY
- deploy/config.js
{
"options": { "accessKeyId": "mycoolkey", "secretAccessKey": "secretsarecool" }
}
note if key & secret aren't found at any of the checks above then you will be prompted for credentials -blocking the deploy (keep this in mind if using with automated/continuous deployment systems).
How to use
ember deploy:s3 --environment=development --aws-key=12345 --aws-secret=asdfasdf --aws-bucket=buckets-o-fun
- this builds a development version of your app and deploys all files in the
/dist
directory to the S3 bucket "buckets-o-fun"
ember deploy:s3
- this will build development version of your app and prompt you for
awsKey
, awsSecret
, and awsBucket
possible cli arguments:
environment
(optional. uses app's default. Passed into deployl/config.js)output-path
(optional. uses app's default /dist
)aws-key
(required. will prompt if not found)aws-secret
(required. will prompt if not found)aws-bucket
(required. will prompt if not provided as cli arg or found in deploy/config.js)aws-region
(optional. will be verified and updated if necessary during deploy process)skip-build
(optional. will skip the build, deploying whatever is in /dist
)
notes camelCase args are okay but they'll be converted to their dasherized version.
Configuring deployment
Generate a config file with ember generate config-s3
(file created at your-app/deploy/config.js)
The environment
is passed into config file, which returns an object containing deploy configuration options.
And here are the pieces to deploy/config.js:
ember-cli-s3-sync Options
{
...
environment: 'development',
promptCredFile: false,
verbose: false,
...
}
{
...
options: {
region: 'us-east-1',
maxRetries: 3,
sslEnabled: true,
params: {
Bucket: 'my-bucket'
},
...
}
Prompt for additional Options:
If you want the deploy process to prompt a user for additional options to be merged in for instantiating the S3 Object:
Uses the inquirer node module.
{
...
additionalOptions: {
type: 'input',
name: 'maxRetries',
'default': 2,
message: 'Please enter a maximum number of retries to attempt when uploading a file',
validate: function(value) {
if ('number' !== typeof value) {
return false;
}
return value;
}
},
...
}
Deploy Steps:
You can run scripts throughout the deploy process. These scripts must exit their process for the deploy to continue running.
beforeBuild
and afterBuild
are not run if you use the --skip-build
flag.
{
...
beforeBuild: [
{
command: 'curl -I http://my-site.nyc?deploy=start',
includeOptions: ['some-option'],
fail: false
}
],
afterBuild: [
...
],
beforeDeploy: [
...
],
afterDeploy: [
...
],
...
}
TODO