diff --git a/aws4.js b/aws4.js index cbe5dc9..c8361c1 100644 --- a/aws4.js +++ b/aws4.js @@ -77,6 +77,10 @@ RequestSigner.prototype.isSingleRegion = function() { } RequestSigner.prototype.createHost = function() { + if(this.request.uri) { + this.request.path = url.parse(this.request.uri).path + return url.parse(this.request.uri).host + } var region = this.isSingleRegion() ? '' : (this.service === 's3' && this.region !== 'us-east-1' ? '-' : '.') + this.region, service = this.service === 'ses' ? 'email' : this.service diff --git a/example.js b/example.js index 6c1a95a..1083c2c 100644 --- a/example.js +++ b/example.js @@ -370,3 +370,16 @@ request(aws4.sign({ //request(aws4.sign({service: 'sdb', path: '/?Action=ListDomains&Version=2009-04-15'})) +// API Gateway with amazonaws domain name +request(aws4.sign({ + uri: 'https://xxxxxx.execute-api.us-west-2.amazonaws.com/v1/required-iam-auth', + service: 'execute-api', + region: 'us-west-2' +})) + +// API Gateway with custom domain name +request(aws4.sign({ + uri: 'https:///required-iam-auth', + service: 'execute-api', + region: 'us-west-2' +}))