@@ -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 ;
@@ -284,10 +302,13 @@ class Client {
284
302
285
303
_uploadFile ( filePath ) {
286
304
let _this = this ,
287
- fileKey = filePath . replace ( _this . clientPath , '' ) . substr ( 1 ) . replace ( / \\ / g, '/' ) ;
305
+ fileKey = filePath . replace ( _this . clientPath , '' ) . substr ( 1 ) . replace ( / \\ / g, '/' ) ,
306
+ urlRoot = regionToUrlRootMap ( _this . region ) ;
288
307
289
308
this . serverless . cli . log ( `Uploading file ${ fileKey } to bucket ${ _this . bucketName } ...` ) ;
290
- this . serverless . cli . log ( `If successful this should be deployed at: https://s3.amazonaws.com/${ _this . bucketName } /${ fileKey } ` )
309
+ this . serverless . cli . log ( 'If successful this should be deployed at:' )
310
+ this . serverless . cli . log ( `https://${ urlRoot } /${ _this . bucketName } /${ fileKey } ` )
311
+ this . serverless . cli . log ( `http://${ _this . bucketName } .${ urlRoot } /${ fileKey } ` )
291
312
292
313
fs . readFile ( filePath , function ( err , fileBuffer ) {
293
314
0 commit comments