Archive · AWS

Lambda Function URLs

Give a Lambda function an HTTPS endpoint without API Gateway (launched April 2022).

1 min read

  • AWS Lambda
  • Python 3.9
  • AWS CLI 2.7

In April 2022 Lambda added function URLs: a built-in HTTPS endpoint for a function, at no extra charge.

# lambda_function.py
def lambda_handler(event, context):
    return {"statusCode": 200, "body": "hello from mumbai"}
zip fn.zip lambda_function.py
aws lambda create-function --function-name hello --runtime python3.9 \
  --handler lambda_function.lambda_handler --zip-file fileb://fn.zip \
  --role arn:aws:iam::111122223333:role/lambda-basic --region ap-south-1
aws lambda create-function-url-config --function-name hello \
  --auth-type AWS_IAM --region ap-south-1

AWS_IAM requires signed requests; NONE makes the URL public, which also needs a resource-based permission for lambda:InvokeFunctionUrl.

Use Choose
Simple webhook or internal endpoint Function URL
Auth with Cognito or JWT, throttling, custom domains, usage plans API Gateway

Check logs in CloudWatch under /aws/lambda/hello. Set a reserved concurrency limit on public functions to cap cost.