@@ -7,6 +7,24 @@ const _ = require('lodash');
7
7
const mime = require ( 'mime' ) ;
8
8
const fs = require ( 'fs' ) ;
9
9
10
+ // per http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_website_region_endpoints
11
+ const regionToUrlRootMap = region => ( {
12
+ 'us-east-2' : 's3-website.us-east-2.amazonaws.com' ,
13
+ 'us-east-1' : 's3-website-us-east-1.amazonaws.com' ,
14
+ 'us-west-1' : 's3-website-us-west-1.amazonaws.com' ,
15
+ 'us-west-2' : 's3-website-us-west-2.amazonaws.com' ,
16
+ 'ca-central-1' : 's3-website.ca-central-1.amazonaws.com' ,
17
+ 'ap-south-1' : 's3-website.ap-south-1.amazonaws.com' ,
18
+ 'ap-northeast-2' : 's3-website.ap-northeast-2.amazonaws.com' ,
19
+ 'ap-southeast-1' : 's3-website-ap-southeast-1.amazonaws.com' ,
20
+ 'ap-southeast-2' : 's3-website-ap-southeast-2.amazonaws.com' ,
21
+ 'ap-northeast-1' : 's3-website-ap-northeast-1.amazonaws.com' ,
22
+ 'eu-central-1' : 's3-website.eu-central-1.amazonaws.com' ,
23
+ 'eu-west-1' : 's3-website-eu-west-1.amazonaws.com' ,
24
+ 'eu-west-2' : 's3-website.eu-west-2.amazonaws.com' ,
25
+ 'sa-east-1' : 's3-website-sa-east-1.amazonaws.com' ,
26
+ } [ region ] )
27
+
10
28
class Client {
11
29
constructor ( serverless , options ) {
12
30
this . serverless = serverless ;
@@ -247,10 +265,13 @@ class Client {
247
265
248
266
_uploadFile ( filePath ) {
249
267
let _this = this ,
250
- fileKey = filePath . replace ( _this . clientPath , '' ) . substr ( 1 ) . replace ( / \\ / g, '/' ) ;
268
+ fileKey = filePath . replace ( _this . clientPath , '' ) . substr ( 1 ) . replace ( / \\ / g, '/' ) ,
269
+ urlRoot = regionToUrlRootMap ( _this . region ) ;
251
270
252
271
this . serverless . cli . log ( `Uploading file ${ fileKey } to bucket ${ _this . bucketName } ...` ) ;
253
- this . serverless . cli . log ( `If successful this should be deployed at: https://s3-${ _this . region } .amazonaws.com/${ _this . bucketName } /${ fileKey } ` )
272
+ this . serverless . cli . log ( 'If successful this should be deployed at:' )
273
+ this . serverless . cli . log ( `https://${ urlRoot } /${ _this . bucketName } /${ fileKey } ` )
274
+ this . serverless . cli . log ( `http://${ _this . bucketName } .${ urlRoot } /${ fileKey } ` )
254
275
255
276
fs . readFile ( filePath , function ( err , fileBuffer ) {
256
277
0 commit comments