learn Lambda function URLs
Notes
Function URLs are best for use cases where you must implement a single-function microservice with a public endpoint that doesn’t require the advanced functionality of API Gateway, such as request validation, throttling, custom authorizers, custom domain names, usage plans, or caching.
- Function URL format
https://<url-id>.lambda-url.<region>.on.aws
- removes the 29s API Gateway limitation. your fn can take 15 min to respond and there is no timeout
- unexpected function URL caching can cause issues
You can throttle the rate of requests that your Lambda function processes through a function URL by configuring reserved concurrency. Reserved concurrency limits the number of maximum concurrent invocations for your function. Your function’s maximum request rate per second (RPS) is equivalent to 10 times the configured reserved concurrency. For example, if you configure your function with a reserved concurrency of 100, then the maximum RPS is 1,000.
- can limit invocations via lambda condiation keys
- AWS Lambda - Permissions - Policy conditions
- Condition keys for AWS Lambda
- aws:SourceIp - can limit lambda invocation by source ip address
Demo
see template.yaml
# deploy
sam deploy --guided
# access lambda url
curl https://klm4pgp5qacvq52o4zptf6avei0cuczb.lambda-url.us-east-1.on.aws/
Resources
- Lambda function URLs
- Announcing AWS Lambda Function URLs: Built-in HTTPS Endpoints for Single-Function Microservices
- Adding a function URL to a CloudFormation template
- SCP to prevent people from creating open Lambda URLs
- use case discussion
Twitter • Reddit