0

This is more of a suggestion that I need.

What is the need for API Gateway when we can directly execute Lambda functions from the apps?

What are the missing pieces provided by API Gateway which we will otherwise miss while using naked lambda?

1 Answers1

0

A few reasons why I've personally picked API Gateway over direct Lambda calls:

Legacy

The obvious cases are Legacy cases, those where you have some component that would require bringing in the AWS SDK to make a Lambda call. Sometimes bringing in the SDK is easy enough, but sometimes, for instance in pure C code, doing so can be onerous. In either case, it's just easier to move from using an existing REST endpoint to AWS's API Gateway, since it's a like-for-like drop in most of the time, just changing or calling a URL.

Direct Access

In some ways, this is a variant of Legacy, but it's much easier to directly access a REST endpoint than it is to access a Lambda endpoint. Notably, it's quite possible to create a Lambda function that returns HTML meant for a human to see through a browser and have them "visit" your Lambda by directly invoking the API gateway serving it up.

Authentication

API Gateways can be unauthenticated, or authenticated with IAM or Cognito. It can be useful to have semi-secret endpoints that any component or user can access without needing to authenticate, or even fully public Lambda endpoints you allow users to access. Or you can use AWS Cognito backed user accounts so your users can access some of your ecosystem without needing IAM accounts themselves.

Cost and Complexity

And for one reason why I avoid using API gateways. There is an added cost. Most of the time it's a small cost, but when you start running something at a large enough scale, the cost of API Gateway can be a factor. And of course, adding API Gateway to your deployment can complicate matters.

Anon Coward
  • 151
  • 3