This sample deploys OTP Authenticator using FastAPI in a Lambda function that is fronted by an HTTP API in API Gateway.
The SAM CLI lets you run APIs locally.
$ 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
$ 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)
$ curl http://127.0.0.1:3000
{"message":"FastAPI running in a Lambda function"}
The SAM CLI is also used to deploy the application.
$ sam build
$ 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
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"}