Go serverless with SwaggerHub and Amazon!

  June 15, 2016

The last few years have brought a gradual shift towards serverless Infrastructure. Infrastructure-as-a-Service (IaaS) has changed the landscape bringing low cost, agility, scalability and reliability to the mix.  The Amazon API Gateway is one such service which needs no introduction. It is a fully managed platform which allows users to build, deploy and manage APIs at any scale. The important aspect of the Amazon API Gateway is that it supports the Swagger definition format for designing and building RESTful APIs, and SwaggerHub is all about the Swagger!

For the unacquainted, SwaggerHub is a free SaaS based product to design and develop your APIs, be it public or internal, using the latest Swagger specification, bringing some of the best tooling of open source framework on one single platform. SwaggerHub provides a host of services to its users, from collaboration to visualize and build APIs in teams, to Integrations, which lets you connect with an array of 3rd party products in your existing toolset.

take me to sh

Life could be so much easier if a developer could use the best tooling available to design the API, from API mocks to the dynamic capabilities of a robust API Editor, and deploy it to the AWS API Gateway, while eliminating the often complex configurations that are needed between the definitions and the Lambda functions.

This is where SwaggerHub’s latest Amazon Gateway Integrations helps. With the Amazon Gateway Integrations, you could expose your API on the Amazon Gateway for consumption, quickly and automatically. Serverless deployment is also taken care of, with SwaggerHub auto-generating the building blocks of your API code in Amazon Lambda from the Swagger definition of SwaggerHub!

SwaggerHub has two API Gateway Integrations available –

  1. Amazon API Gateway
  2. Amazon API Gateway Lambda Sync

To see the Integration in action, check out this short screencast!

videDemo

Amazon API Gateway

The Amazon API Gateway allows you to quickly deploy your API on the Amazon Gateway in proxy mode, which lets the Gateway handle stuff like rate limiting and authentication. Users can add the proxy to the Integration which would connect the API to the AWS Service. This will also keep the definition in sync with your API on the Gateway.

API Gateway

Amazon API Gateway - Lambda Sync

AWS Lambda is a compute service which runs code without provisioning or managing servers. The AWS Lambda can run code for any application or backend service, and the Integration lets users create and match Lambda functions with the operationId of the Swagger definition. The Integration can be configured to keep the API definition in sync with the Lambda functions and the API Gateway.  The Lambda Sync Integration does the complicated plumbing for you on the Gateway, meaning users will only have to worry about the true business value of the app.

API Gateway Lambda

Lambda functions are created and matched by the operationId in each operation. If you do not have an operationId (they are optional in the OpenAPI Specification), one will be created for you. If a lambda function exists with the same name as the operationId, it will be used, and a new function will not be created.

To see the Integration in action, check out this short screencast!

videDemo

The above Integrations can be wired to best suit your workflow. These two Integrations are powerful tools to take your API from design to deployment in the most efficient way possible using the AWS API Gateway. Using SwaggerHub, which offers the best tooling there is for designing the API, and combining it with the scalablity and reliability of the AWS Gateway, is bound to make your API development process a walk in the park!