Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ ember install ember-cli-deploy-elastic-beanstalk

## A Note on AWS Permissions

This plugin relies on the official AWS SDK to perform uploads to S3. As
This plugin uses the official AWS SDK to perform uploads to S3. As
such, it will inherit any credentials you have saved by running `aws
configure` via the [AWS CLI][aws-cli].
configure` via the [AWS CLI][aws-cli]. For environments where it is not feasible
to use `aws configure` (e.g. your CI environment like Travis), you can additionally
specify an `accessKeyId` and `secretAccessKey` as a configuration option for this
ember-cli-deploy plugin in the `deploy.js` file.


[aws-cli]: https://aws.amazon.com/cli/

Expand Down Expand Up @@ -123,6 +127,20 @@ The path to the zip file that should be created from the `outputPath`.

*Default:* `tmp/fastboot-dist.zip`


### accessKeyId

The AWS access key for the user that has the ability to upload to the `bucket`. If this is left undefined,
the normal [AWS SDK credential resolution][5] will take place.

*Default:* `undefined`

### secretAccessKey

The AWS secret for the user that has the ability to upload to the `bucket`. This must be defined when `accessKeyId` is defined.

*Default:* `undefined`

### filesToExclude

Files that match this pattern will be excluded from the `zip`. For instance to
Expand Down
11 changes: 8 additions & 3 deletions lib/aws/s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ const AWS = require('aws-sdk');
class S3 {
constructor(options) {
options = options || {};

this.s3 = new AWS.S3({
let s3Options = {
apiVersion: '2006-03-01',
region: options.region
});
};
if (options.accessKeyId && options.secretAccessKey) {
s3Options.accessKeyId = options.accessKeyId;
s3Options.secretAccessKey = options.secretAccessKey;
}

this.s3 = new AWS.S3(s3Options);
}

listBuckets() {
Expand Down
6 changes: 5 additions & 1 deletion lib/elastic-beanstalk-deploy-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,18 @@ module.exports = DeployPlugin.extend({
let region = this.readConfig('region');
let bucket = this.readConfig('bucket');
let key = this.readConfig('key');
let accessKeyId = this.readConfig('accessKeyId');
let secretAccessKey = this.readConfig('secretAccessKey');

let uploadTask = new UploadTask({
context: context,
log: this.log.bind(this),
hashedZipPath: context.hashedZipPath,
region: region,
bucket: bucket,
key: key
key: key,
accessKeyId: accessKeyId,
secretAccessKey: secretAccessKey
});

return uploadTask.run();
Expand Down
8 changes: 7 additions & 1 deletion lib/tasks/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ class UploadTask {
this.key = options.key;
this.hashedZipPath = options.hashedZipPath;
this.hashedZipKey = path.basename(this.hashedZipPath);
this.s3 = new S3({ region: options.region });

let s3Opts = { region: options.region };
if (options.accessKeyId && options.secretAccessKey) {
s3Opts.accessKeyId = options.accessKeyId;
s3Opts.secretAccessKey = options.secretAccessKey;
}
this.s3 = new S3(s3Opts);
}

run() {
Expand Down