Giter VIP home page Giter VIP logo

lambda-function-with-cloudformation's Introduction

Deploy FastAPI on AWS: Lambda + API Gateway

This sample deploys OTP Authenticator using FastAPI in a Lambda function that is fronted by an HTTP API in API Gateway.

Requirements

Run Locally

The SAM CLI lets you run APIs locally.

Build the application

$ sam build

...

Build Succeeded

Built Artifacts  : .aws-sam/build
Built Template   : .aws-sam/build/template.yaml

Commands you can use next
=========================
[*] Invoke Function: sam local invoke
[*] Deploy: sam deploy --guided

Start the API locally

$ sam local start-api

Mounting Function at http://127.0.0.1:3000$default [X-AMAZON-APIGATEWAY-ANY-METHOD]
You can now browse to the above endpoints to invoke your functions.

2021-11-14 22:20:56  * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)

Call the API

$ curl http://127.0.0.1:3000

{"message":"FastAPI running in a Lambda function"}

Deploy

The SAM CLI is also used to deploy the application.

Build

$ sam build 

Deploy

$ sam deploy --guided
...

CloudFormation outputs from deployed stack
---------------------------------------------------------------------------
Outputs
---------------------------------------------------------------------------
Key                 ApiUrl
Description         URL of your API endpoint
Value               https://API_ID.execute-api.eu-west-1.amazonaws.com/
---------------------------------------------------------------------------

Successfully created/updated stack - FastAPIOnLambda in eu-west-1

Call the API

The URL of your API Gateway is shown in the outputs section of the sam deploy command.

$ curl https://API_ID.execute-api.eu-west-1.amazonaws.com/

{"message":"FastAPI running in a Lambda function"}

lambda-function-with-cloudformation's People

Contributors

nictsyen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.