Repository: aws/aws-sdk-js
Pull request #1793 (2017-11-09 23:58:56)

Update s3 endpoint patterns
This PR updates the `region_config_data.json` file to match [this change](https://github.com/aws/aws-sdk-ruby/commit/b86facf20d6c94493850e177b101f14140f05694#diff-379153f5c18f31157dc36046cd16434c)

codecov-io: # [Codecov](https://codecov.io/gh/aws/aws-sdk-js/pull/1793?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@1ecbb24`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/aws/aws-sdk-js/pull/1793/graphs/tree.svg?height=150&src=pr&token=qXdPGBZWAr&width=650)](https://codecov.io/gh/aws/aws-sdk-js/pull/1793?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##             master    #1793   +/-   ##
=========================================
  Coverage          ?   95.73%           
=========================================
  Files             ?      190           
  Lines             ?     6640           
  Branches          ?     1356           
=========================================
  Hits              ?     6357           
  Misses            ?      283           
  Partials          ?        0
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/aws/aws-sdk-js/pull/1793?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/aws/aws-sdk-js/pull/1793?src=pr&el=footer). Last update [1ecbb24...2715358](https://codecov.io/gh/aws/aws-sdk-js/pull/1793?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/lib/region_config_data.json b/lib/region_config_data.json
index b0fb0e894..0d23d720a 100644
--- a/lib/region_config_data.json
+++ b/lib/region_config_data.json
@@ -25,14 +25,6 @@
     "us-gov-*/sts": {
       "endpoint": "{service}.{region}.amazonaws.com"
     },
-    "us-gov-west-1/s3": "s3dash",
-    "us-west-1/s3": "s3dash",
-    "us-west-2/s3": "s3dash",
-    "eu-west-1/s3": "s3dash",
-    "ap-southeast-1/s3": "s3dash",
-    "ap-southeast-2/s3": "s3dash",
-    "ap-northeast-1/s3": "s3dash",
-    "sa-east-1/s3": "s3dash",
     "us-east-1/s3": {
       "endpoint": "{service}.amazonaws.com",
       "signatureVersion": "s3"


Test patch:
diff --git a/test/region_config.spec.js b/test/region_config.spec.js
index 82e6c5aa3..4f934d3d1 100644
--- a/test/region_config.spec.js
+++ b/test/region_config.spec.js
@@ -1,158 +1,147 @@
-// Generated by CoffeeScript 1.12.3
-(function() {
-  var AWS, EventEmitter, MockService, helpers;
+var helpers = require('./helpers');
+var AWS = helpers.AWS;
+var MockService = helpers.MockService;
 
-  helpers = require('./helpers');
-
-  EventEmitter = require('events').EventEmitter;
+describe('region_config.js', function() {
+  it('sets endpoint configuration option for default regions', function() {
+    var service = new MockService;
+    expect(service.isGlobalEndpoint).to.equal(false);
+    expect(service.endpoint.host).to.equal('mockservice.mock-region.amazonaws.com');
+  });
 
-  AWS = helpers.AWS;
+  [AWS.CloudFront, AWS.IAM, AWS.ImportExport, AWS.Route53].forEach(function(svcClass) {
+    it('uses a global endpoint for ' + svcClass.serviceIdentifier, function() {
+      var service = new svcClass;
+      expect(service.endpoint.host).to.equal(service.serviceIdentifier + '.amazonaws.com');
+      expect(service.isGlobalEndpoint).to.equal(true);
+    });
+  });
 
-  MockService = helpers.MockService;
+  it('always enables SSL for Route53', function() {
+    var service = new AWS.Route53;
+    expect(service.config.sslEnabled).to.equal(true);
+  });
 
-  describe('region_config.js', function() {
-    it('sets endpoint configuration option for default regions', function() {
-      var service;
-      service = new MockService;
-      expect(service.isGlobalEndpoint).to.equal(false);
-      return expect(service.endpoint.host).to.equal('mockservice.mock-region.amazonaws.com');
+  it('uses "global" endpoint for SimpleDB in us-east-1', function() {
+    var service = new AWS.SimpleDB({
+      region: 'us-east-1'
     });
-    [AWS.CloudFront, AWS.IAM, AWS.ImportExport, AWS.Route53].forEach(function(svcClass) {
-      return it('uses a global endpoint for ' + svcClass.serviceIdentifier, function() {
-        var service;
-        service = new svcClass;
-        expect(service.endpoint.host).to.equal(service.serviceIdentifier + '.amazonaws.com');
-        return expect(service.isGlobalEndpoint).to.equal(true);
-      });
+    expect(service.isGlobalEndpoint).to.equal(false);
+    expect(service.endpoint.host).to.equal('sdb.amazonaws.com');
+  });
+
+  it('uses "global" endpoint for SimpleDB in us-east-1', function() {
+    var service = new AWS.S3({
+      region: 'us-east-1'
     });
-    it('always enables SSL for Route53', function() {
-      var service;
-      service = new AWS.Route53;
-      return expect(service.config.sslEnabled).to.equal(true);
+    expect(service.isGlobalEndpoint).to.equal(false);
+    expect(service.endpoint.host).to.equal('s3.amazonaws.com');
+  });
+
+  it('does not use any global endpoints in cn-*', function() {
+    var service = new AWS.IAM({
+      region: 'cn-north-1'
     });
-    it('uses "global" endpoint for SimpleDB in us-east-1', function() {
-      var service;
-      service = new AWS.SimpleDB({
-        region: 'us-east-1'
-      });
-      expect(service.isGlobalEndpoint).to.equal(false);
-      return expect(service.endpoint.host).to.equal('sdb.amazonaws.com');
+    expect(service.isGlobalEndpoint).to.equal(false);
+    expect(service.endpoint.host).to.equal('iam.cn-north-1.amazonaws.com.cn');
+  });
+
+  it('enables signature version 4 signing in cn-*', function() {
+    var service = new AWS.IAM({
+      region: 'cn-north-1'
     });
-    it('uses "global" endpoint for SimpleDB in us-east-1', function() {
-      var service;
-      service = new AWS.S3({
-        region: 'us-east-1'
-      });
-      expect(service.isGlobalEndpoint).to.equal(false);
-      return expect(service.endpoint.host).to.equal('s3.amazonaws.com');
+    expect(service.config.signatureVersion).to.equal('v4');
+  });
+
+  it('does not use - as separator for S3 in public regions and GovCloud', function() {
+    var service = new AWS.S3({
+      region: 'us-west-2'
     });
-    it('does not use any global endpoints in cn-*', function() {
-      var service;
-      service = new AWS.IAM({
-        region: 'cn-north-1'
-      });
-      expect(service.isGlobalEndpoint).to.equal(false);
-      return expect(service.endpoint.host).to.equal('iam.cn-north-1.amazonaws.com.cn');
+    expect(service.isGlobalEndpoint).to.equal(false);
+    expect(service.endpoint.host).to.equal('s3.us-west-2.amazonaws.com');
+    service = new AWS.S3({
+      region: 'us-gov-west-1'
     });
-    it('enables signature version 4 signing in cn-*', function() {
-      var service;
-      service = new AWS.IAM({
-        region: 'cn-north-1'
-      });
-      return expect(service.config.signatureVersion).to.equal('v4');
+    expect(service.isGlobalEndpoint).to.equal(false);
+    expect(service.endpoint.host).to.equal('s3.us-gov-west-1.amazonaws.com');
+  });
+
+  it('uses . as separator for S3 in cn-*', function() {
+    var service = new AWS.S3({
+      region: 'cn-north-1'
     });
-    it('uses - as separator for S3 in public regions and GovCloud', function() {
-      var service;
-      service = new AWS.S3({
-        region: 'us-west-2'
-      });
-      expect(service.isGlobalEndpoint).to.equal(false);
-      expect(service.endpoint.host).to.equal('s3-us-west-2.amazonaws.com');
-      service = new AWS.S3({
-        region: 'us-gov-west-1'
-      });
-      expect(service.isGlobalEndpoint).to.equal(false);
-      return expect(service.endpoint.host).to.equal('s3-us-gov-west-1.amazonaws.com');
+    expect(service.isGlobalEndpoint).to.equal(false);
+    expect(service.endpoint.host).to.equal('s3.cn-north-1.amazonaws.com.cn');
+  });
+
+  it('uses SigV4 and . for default regions', function() {
+    var service = new AWS.S3({
+      region: 'xx-west-1'
     });
-    it('uses . as separator for S3 in cn-*', function() {
-      var service;
-      service = new AWS.S3({
-        region: 'cn-north-1'
-      });
-      expect(service.isGlobalEndpoint).to.equal(false);
-      return expect(service.endpoint.host).to.equal('s3.cn-north-1.amazonaws.com.cn');
+    expect(service.isGlobalEndpoint).to.equal(false);
+    expect(service.config.signatureVersion).to.equal('v4');
+    expect(service.endpoint.host).to.equal('s3.xx-west-1.amazonaws.com');
+  });
+
+  it('uses us-gov endpoint for IAM in GovCloud', function() {
+    var service = new AWS.IAM({
+      region: 'us-gov-west-1'
     });
-    it('uses SigV4 and . for default regions', function() {
-      var service;
-      service = new AWS.S3({
-        region: 'xx-west-1'
-      });
-      expect(service.isGlobalEndpoint).to.equal(false);
-      expect(service.config.signatureVersion).to.equal('v4');
-      return expect(service.endpoint.host).to.equal('s3.xx-west-1.amazonaws.com');
+    expect(service.isGlobalEndpoint).to.equal(false);
+    expect(service.endpoint.host).to.equal('iam.us-gov.amazonaws.com');
+  });
+
+  it('uses us-gov-west-1 endpoint for STS in GovCloud', function() {
+    var service = new AWS.STS({
+      region: 'us-gov-west-1'
     });
-    it('uses us-gov endpoint for IAM in GovCloud', function() {
-      var service;
-      service = new AWS.IAM({
-        region: 'us-gov-west-1'
+    expect(service.isGlobalEndpoint).to.equal(false);
+    expect(service.endpoint.host).to.equal('sts.us-gov-west-1.amazonaws.com');
+  });
+
+  describe('dualstack endpoint', function() {
+    it('uses dualstack endpoint if useDualstack flag configured and available for service', function() {
+      helpers.spyOn(AWS.util, 'isDualstackAvailable').andReturn(true);
+      var service = new MockService({
+        region: 'us-west-2',
+        useDualstack: true
       });
-      expect(service.isGlobalEndpoint).to.equal(false);
-      return expect(service.endpoint.host).to.equal('iam.us-gov.amazonaws.com');
+      expect(service.config.endpoint).to.equal('mockservice.dualstack.us-west-2.amazonaws.com');
     });
-    it('uses us-gov-west-1 endpoint for STS in GovCloud', function() {
-      var service;
-      service = new AWS.STS({
-        region: 'us-gov-west-1'
+
+    it('does not use dualstack endpoint if useDualstack flag not set to true', function() {
+      helpers.spyOn(AWS.util, 'isDualstackAvailable').andReturn(true);
+      var service = new MockService({
+        region: 'us-west-2'
       });
-      expect(service.isGlobalEndpoint).to.equal(false);
-      return expect(service.endpoint.host).to.equal('sts.us-gov-west-1.amazonaws.com');
+      expect(service.config.endpoint).to.equal('mockservice.us-west-2.amazonaws.com');
     });
-    return describe('dualstack endpoint', function() {
-      it('uses dualstack endpoint if useDualstack flag configured and available for service', function() {
-        var service;
-        helpers.spyOn(AWS.util, 'isDualstackAvailable').andReturn(true);
-        service = new MockService({
-          region: 'us-west-2',
-          useDualstack: true
-        });
-        return expect(service.config.endpoint).to.equal('mockservice.dualstack.us-west-2.amazonaws.com');
-      });
-      it('does not use dualstack endpoint if useDualstack flag not set to true', function() {
-        var service;
-        helpers.spyOn(AWS.util, 'isDualstackAvailable').andReturn(true);
-        service = new MockService({
-          region: 'us-west-2'
-        });
-        return expect(service.config.endpoint).to.equal('mockservice.us-west-2.amazonaws.com');
-      });
-      return it('does not use dualstack endpoint if not available for service', function() {
-        var service;
-        helpers.spyOn(AWS.util, 'isDualstackAvailable').andReturn(false);
-        service = new MockService({
-          region: 'us-west-2',
-          useDualstack: true
-        });
-        return expect(service.config.endpoint).to.equal('mockservice.us-west-2.amazonaws.com');
+
+    it('does not use dualstack endpoint if not available for service', function() {
+      helpers.spyOn(AWS.util, 'isDualstackAvailable').andReturn(false);
+      var service = new MockService({
+        region: 'us-west-2',
+        useDualstack: true
       });
+      expect(service.config.endpoint).to.equal('mockservice.us-west-2.amazonaws.com');
     });
   });
+});
 
-  describe('region_config_data.json', function() {
-    return it('does not reference undefined patterns', function() {
-      var config, k, ref, results, v;
-      config = require('../lib/region_config_data.json');
-      ref = config.rules;
-      results = [];
-      for (k in ref) {
-        v = ref[k];
-        if (typeof v === 'string') {
-          results.push(expect(config.patterns).to.haveOwnProperty(v));
-        } else {
-          results.push(void 0);
-        }
+describe('region_config_data.json', function() {
+  it('does not reference undefined patterns', function() {
+    var config, k, ref, results, v;
+    config = require('../lib/region_config_data.json');
+    ref = config.rules;
+    results = [];
+    for (k in ref) {
+      v = ref[k];
+      if (typeof v === 'string') {
+        results.push(expect(config.patterns).to.haveOwnProperty(v));
+      } else {
+        results.push(void 0);
       }
-      return results;
-    });
+    }
+    return results;
   });
-
-}).call(this);
+});
diff --git a/test/services/s3.spec.js b/test/services/s3.spec.js
index f1780a51d..fd1791019 100644
--- a/test/services/s3.spec.js
+++ b/test/services/s3.spec.js
@@ -87,11 +87,11 @@ describe('AWS.S3', function() {
       expect(s3.config.region).to.equal('us-east-1');
     });
 
-    it('combines the region with s3 in the endpoint using a - instead of .', function() {
+    it('combines the region with s3 in the endpoint using a .', function() {
       s3 = new AWS.S3({
         region: 'us-west-1'
       });
-      expect(s3.endpoint.hostname).to.equal('s3-us-west-1.amazonaws.com');
+      expect(s3.endpoint.hostname).to.equal('s3.us-west-1.amazonaws.com');
     });
 
     it('sets a region-specific dualstack endpoint when dualstack enabled', function() {
@@ -554,8 +554,8 @@ describe('AWS.S3', function() {
       req = s3.headBucket(param).build();
       httpRequest = req.httpRequest;
       expect(httpRequest.region).to.equal('us-west-2');
-      expect(httpRequest.endpoint.hostname).to.equal('name.s3-us-west-2.amazonaws.com');
-      expect(httpRequest.headers.Host).to.equal('name.s3-us-west-2.amazonaws.com');
+      expect(httpRequest.endpoint.hostname).to.equal('name.s3.us-west-2.amazonaws.com');
+      expect(httpRequest.headers.Host).to.equal('name.s3.us-west-2.amazonaws.com');
       expect(httpRequest.path).to.equal('/');
     });
 
@@ -572,8 +572,8 @@ describe('AWS.S3', function() {
       req = s3.headBucket(param).build();
       httpRequest = req.httpRequest;
       expect(httpRequest.region).to.equal('us-west-2');
-      expect(httpRequest.endpoint.hostname).to.equal('s3-us-west-2.amazonaws.com');
-      expect(httpRequest.headers.Host).to.equal('s3-us-west-2.amazonaws.com');
+      expect(httpRequest.endpoint.hostname).to.equal('s3.us-west-2.amazonaws.com');
+      expect(httpRequest.headers.Host).to.equal('s3.us-west-2.amazonaws.com');
       expect(httpRequest.path).to.equal('/name');
     });
 
@@ -1493,7 +1493,7 @@ describe('AWS.S3', function() {
       var retryable = s3.retryableError(err, req);
       expect(retryable).to.equal(true);
       expect(req.httpRequest.region).to.equal('eu-west-1');
-      expect(req.httpRequest.endpoint.hostname).to.equal('name.s3-eu-west-1.amazonaws.com');
+      expect(req.httpRequest.endpoint.hostname).to.equal('name.s3.eu-west-1.amazonaws.com');
     });
 
     it('should retry on error code 301 with updated region and endpoint', function() {
@@ -1509,7 +1509,7 @@ describe('AWS.S3', function() {
       var retryable = s3.retryableError(err, req);
       expect(retryable).to.equal(true);
       expect(req.httpRequest.region).to.equal('eu-west-1');
-      expect(req.httpRequest.endpoint.hostname).to.equal('name.s3-eu-west-1.amazonaws.com');
+      expect(req.httpRequest.endpoint.hostname).to.equal('name.s3.eu-west-1.amazonaws.com');
     });
 
     it('should retry with updated region but not endpoint if non-S3 url endpoint is specified', function() {
@@ -1539,7 +1539,7 @@ describe('AWS.S3', function() {
         region: 'eu-west-1'
       };
       s3 = new AWS.S3({
-        endpoint: 'https://name.s3-us-west-2.amazonaws.com',
+        endpoint: 'https://name.s3.us-west-2.amazonaws.com',
         s3BucketEndpoint: true
       });
       var req = request('operation', {
@@ -1549,7 +1549,7 @@ describe('AWS.S3', function() {
       var retryable = s3.retryableError(err, req);
       expect(retryable).to.equal(true);
       expect(req.httpRequest.region).to.equal('eu-west-1');
-      expect(req.httpRequest.endpoint.hostname).to.equal('name.s3-eu-west-1.amazonaws.com');
+      expect(req.httpRequest.endpoint.hostname).to.equal('name.s3.eu-west-1.amazonaws.com');
     });
 
     it('should retry with updated region but not endpoint if accelerate endpoint is used', function() {
@@ -1663,7 +1663,7 @@ describe('AWS.S3', function() {
       s3.bucketRegionCache.name = 'eu-west-1';
       callNetworkingErrorListener(req);
       expect(req.httpRequest.region).to.equal('eu-west-1');
-      expect(req.httpRequest.endpoint.hostname).to.equal('name.s3-eu-west-1.amazonaws.com');
+      expect(req.httpRequest.endpoint.hostname).to.equal('name.s3.eu-west-1.amazonaws.com');
       expect(spy.calls.length).to.equal(0);
     });
 
@@ -1677,7 +1677,7 @@ describe('AWS.S3', function() {
       expect(regionReq.httpRequest.region).to.equal('us-east-1');
       expect(regionReq.httpRequest.endpoint.hostname).to.equal('name.s3.amazonaws.com');
       expect(req.httpRequest.region).to.equal('eu-west-1');
-      expect(req.httpRequest.endpoint.hostname).to.equal('name.s3-eu-west-1.amazonaws.com');
+      expect(req.httpRequest.endpoint.hostname).to.equal('name.s3.eu-west-1.amazonaws.com');
     });
 
     it('makes async request in us-east-1 if cached region matches current region', function() {
@@ -1691,7 +1691,7 @@ describe('AWS.S3', function() {
       expect(regionReq.httpRequest.region).to.equal('us-east-1');
       expect(regionReq.httpRequest.endpoint.hostname).to.equal('name.s3.amazonaws.com');
       expect(req.httpRequest.region).to.equal('eu-west-1');
-      expect(req.httpRequest.endpoint.hostname).to.equal('name.s3-eu-west-1.amazonaws.com');
+      expect(req.httpRequest.endpoint.hostname).to.equal('name.s3.eu-west-1.amazonaws.com');
     });
 
     it('does not update region if path-style bucket is dns-compliant and not in cache', function() {
@@ -1703,7 +1703,7 @@ describe('AWS.S3', function() {
       var req = callNetworkingErrorListener();
       expect(spy.calls.length).to.equal(0);
       expect(req.httpRequest.region).to.equal('us-west-2');
-      expect(req.httpRequest.endpoint.hostname).to.equal('s3-us-west-2.amazonaws.com');
+      expect(req.httpRequest.endpoint.hostname).to.equal('s3.us-west-2.amazonaws.com');
     });
   });