Skip to content

Commit

Permalink
add PRIVATE endpointType
Browse files Browse the repository at this point in the history
  • Loading branch information
ijin committed Jun 27, 2018
1 parent 0e60b12 commit 88459f9
Show file tree
Hide file tree
Showing 4 changed files with 1,585 additions and 1,564 deletions.
2 changes: 1 addition & 1 deletion docs/providers/aws/events/apigateway.md
Expand Up @@ -472,7 +472,7 @@ Clients connecting to this Rest API will then need to set any of these API keys

API Gateway [supports regional endpoints](https://aws.amazon.com/about-aws/whats-new/2017/11/amazon-api-gateway-supports-regional-api-endpoints/) for associating your API Gateway REST APIs with a particular region. This can reduce latency if your requests originate from the same region as your REST API and can be helpful in building multi-region applications.

By default, the Serverless Framework deploys your REST API using the EDGE endpoint configuration. If you would like to use the REGIONAL configuration, set the `endpointType` parameter in your `provider` block.
By default, the Serverless Framework deploys your REST API using the EDGE endpoint configuration. If you would like to use the REGIONAL or PRIVATE configuration, set the `endpointType` parameter in your `provider` block.

Here's an example configuration for setting the endpoint configuration for your service Rest API:

Expand Down
Expand Up @@ -15,7 +15,7 @@ module.exports = {
let endpointType = 'EDGE';

if (this.serverless.service.provider.endpointType) {
const validEndpointTypes = ['REGIONAL', 'EDGE'];
const validEndpointTypes = ['REGIONAL', 'EDGE', 'PRIVATE'];
endpointType = this.serverless.service.provider.endpointType;

if (typeof endpointType !== 'string') {
Expand All @@ -24,7 +24,7 @@ module.exports = {


if (!_.includes(validEndpointTypes, endpointType.toUpperCase())) {
const message = 'endpointType must be one of "REGIONAL" or "EDGE". ' +
const message = 'endpointType must be one of "REGIONAL" or "EDGE" or "PRIVATE". ' +
`You provided ${endpointType}.`;
throw new this.serverless.classes.Error(message);
}
Expand Down
Expand Up @@ -81,6 +81,16 @@ describe('#compileRestApi()', () => {
expect(() => awsCompileApigEvents.compileRestApi()).to.throw(Error);
});

it('should compile if endpointType property is REGIONAL', () => {
awsCompileApigEvents.serverless.service.provider.endpointType = 'REGIONAL';
expect(() => awsCompileApigEvents.compileRestApi()).to.not.throw(Error);
});

it('should compile if endpointType property is PRIVATE', () => {
awsCompileApigEvents.serverless.service.provider.endpointType = 'PRIVATE';
expect(() => awsCompileApigEvents.compileRestApi()).to.not.throw(Error);
});

it('throw error if endpointType property is not EDGE or REGIONAL', () => {
awsCompileApigEvents.serverless.service.provider.endpointType = 'Testing';
expect(() => awsCompileApigEvents.compileRestApi()).to.throw('endpointType must be one of');
Expand Down

0 comments on commit 88459f9

Please sign in to comment.