AWS Classic

Pulumi Official
Package maintained by Pulumi
v5.9.1 published on Tuesday, Jun 21, 2022 by Pulumi

Lambda-backed API Gateway

View Code

This example provides API endpoints which are executed by AWS Lambda using Python. The example sets up up two Lambda-backed API Gateways: an API Gateway V1 (REST) and an API Gateway V2 (HTTP). AWS provides some information on the differences between these two API Gateway types: Announcing HTTP APIs for Amazon API Gateway and API Gateway V2 FAQs

This sample uses the following AWS products:

Prerequisites

  1. Install Pulumi

  2. Create a new stack:

    $ pulumi stack init aws-py-apigateway-lambda-serverless
    
  3. Set the AWS region:

    $ pulumi config set aws:region us-east-2
    

Deploy the App

  1. Run pulumi up to preview and deploy changes:

  2. To view the runtime logs of the Lambda function, use the pulumi logs command. To get a log stream, use pulumi logs --follow.

Clean Up

  1. Run pulumi destroy to tear down all resources.

  2. To delete the stack itself, run pulumi stack rm. Note that this command deletes all deployment history from the Pulumi Console.

Summary

In this tutorial, you built a lambda-backed API on AWS using API Gateway, lambda functions, and Pulumi. This serverless solution is highly scaleable, resilient, and stateless.

Next Steps