Skip to content

Commit b7f019b

Browse files
author
Seth Pollack
committed
Add Server Side Encryption
1 parent 14178e9 commit b7f019b

File tree

3 files changed

+37
-20
lines changed

3 files changed

+37
-20
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ The network proxy url used when sending requests to S3.
195195

196196
*Default:* `undefined`
197197

198+
### serverSideEncryption
199+
200+
The Server-side encryption algorithm used when storing this object in S3 (e.g., AES256, aws:kms). Possible values include:
201+
- "AES256"
202+
- "aws:kms"
203+
198204
## Prerequisites
199205

200206
The following properties are expected to be present on the deployment `context` object:

index.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,20 @@ module.exports = {
4545
requiredConfig: ['bucket', 'region'],
4646

4747
upload: function(context) {
48-
var self = this;
48+
var self = this;
4949

50-
var filePattern = this.readConfig('filePattern');
51-
var distDir = this.readConfig('distDir');
52-
var distFiles = this.readConfig('distFiles');
53-
var gzippedFiles = this.readConfig('gzippedFiles');
54-
var bucket = this.readConfig('bucket');
55-
var acl = this.readConfig('acl');
56-
var prefix = this.readConfig('prefix');
57-
var manifestPath = this.readConfig('manifestPath');
58-
var cacheControl = this.readConfig('cacheControl');
59-
var expires = this.readConfig('expires');
60-
var dotFolders = this.readConfig('dotFolders');
50+
var filePattern = this.readConfig('filePattern');
51+
var distDir = this.readConfig('distDir');
52+
var distFiles = this.readConfig('distFiles');
53+
var gzippedFiles = this.readConfig('gzippedFiles');
54+
var bucket = this.readConfig('bucket');
55+
var acl = this.readConfig('acl');
56+
var prefix = this.readConfig('prefix');
57+
var manifestPath = this.readConfig('manifestPath');
58+
var cacheControl = this.readConfig('cacheControl');
59+
var expires = this.readConfig('expires');
60+
var dotFolders = this.readConfig('dotFolders');
61+
var serverSideEncryption = this.readConfig('serverSideEncryption');
6162

6263
var filesToUpload = distFiles.filter(minimatch.filter(filePattern, { matchBase: true, dot: dotFolders }));
6364

@@ -77,6 +78,10 @@ module.exports = {
7778
expires: expires
7879
};
7980

81+
if (serverSideEncryption) {
82+
options.serverSideEncryption = serverSideEncryption;
83+
}
84+
8085
this.log('preparing to upload to S3 bucket `' + bucket + '`', { verbose: true });
8186

8287
return s3.upload(options)

lib/s3.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,15 @@ module.exports = CoreObject.extend({
9797
},
9898

9999
_putObjects: function(filePaths, options) {
100-
var plugin = this._plugin;
101-
var cwd = options.cwd;
102-
var bucket = options.bucket;
103-
var prefix = options.prefix;
104-
var acl = options.acl;
105-
var gzippedFilePaths = options.gzippedFilePaths || [];
106-
var cacheControl = options.cacheControl;
107-
var expires = options.expires;
100+
var plugin = this._plugin;
101+
var cwd = options.cwd;
102+
var bucket = options.bucket;
103+
var prefix = options.prefix;
104+
var acl = options.acl;
105+
var gzippedFilePaths = options.gzippedFilePaths || [];
106+
var cacheControl = options.cacheControl;
107+
var expires = options.expires;
108+
var serverSideEncryption = options.serverSideEncryption;
108109

109110
mime.default_type = options.defaultMimeType || mime.lookup('bin');
110111

@@ -138,6 +139,11 @@ module.exports = CoreObject.extend({
138139
CacheControl: cacheControl,
139140
Expires: expires
140141
};
142+
143+
if (serverSideEncryption) {
144+
params.ServerSideEncryption = serverSideEncryption;
145+
}
146+
141147
if (isGzipped) {
142148
params.ContentEncoding = 'gzip';
143149
}

0 commit comments

Comments
 (0)