Chapter 3. Your function as a web API

 

This chapter covers

  • Introducing the Amazon API Gateway
  • Exposing functions as web APIs
  • Customizing the integration between web API and function
  • Testing the web API from the web console, a browser, or the command line
  • Using the API Gateway context in a function

In the previous chapter you built your first AWS Lambda function, learned how to configure the function, edited the code, and quickly tested the function from the web console. You then used the function via the AWS command-line interface (CLI).

In this chapter you’ll make your function available over HTTP as a web API using the Amazon API Gateway. You’ll learn how to integrate a Lambda function with the API Gateway and test that using the web console, a browser, or a command-line tool. You’ll also build a new Lambda function to see how the API Gateway context can be used by a function to have more information about who’s calling the web API.

3.1. Introducing the Amazon API Gateway

You’ve learned how to create a single function using AWS Lambda and invoke the function using the Invoke API via the AWS CLI. A similar syntax can be used with any AWS SDK. How can you extend that knowledge to create a web API?

One of the advantages of AWS Lambda is the integration with the Amazon API Gateway to access AWS Lambda functions without using the AWS APIs, CLI, or SDKs: you can use functions via a web API that you design.

3.2. Creating the API

3.3. Creating the integration

3.4. Testing the integration

3.5. Transforming the response

3.6. Using resource paths as parameters

3.7. Using the API Gateway context

Summary

Exercise

sitemap