AWS Service Integration

Understand how API Gateway can communicate with AWS services directly, without a Lambda function.

Service integration

AWS is a collection of RESTful web services (hence the name). All services in AWS expose an API that we can invoke with the necessary authentication. AWS services are available over HTTP without the API Gateway. In theory, it’s possible to invoke them remotely, even from the browser, but that requires extreme caution to follow the elaborate authentication framework. Otherwise, it can pose a security risk, which we want to avoid.

To understand this, open the AWS console in a browser. Then, open the browser’s developer tools and monitor the network traffic. A single click anywhere in the console generates more than fifteen API calls that manage the tokens and other handshakes required to protect the data flowing either way. We don't want to take all that effort into our applications.

That’s why we have the API Gateway!

Just as we configured the API Gateway to invoke a Lambda function or an external API, we can set it up to invoke any AWS service. Such integration would be more secure as we expose only a restricted part of the service to the external world through the protected interface of the API Gateway.

Sample application

We’ve seen a Lambda function that increments a value in DynamoDB and returns the updated value. Let’s implement an API gateway integration that can access the database without a Lambda function.

Check out the code below.

Get hands-on with 1200+ tech skills courses.