AWS Lambda Function URL, Create Web Apis without API Gateway

Nowadays microservices pattern is industry standard and there are many ways to create microservices. Container platforms like K8S, AWS Farget, and many others are used to deploy microservices, apart from these Functions as service is another way to create microservices using API gateways.

On AWS one can develop APIs using AWS Lambda and API gateway service. But last week AWS announces one more feature Enable function URL in the Lambda function service. Using this developer can expose the lambda function with a unique URL.

For each Function URL, AWS will generate a globally unique URL. Functionction URL can be associated with function alias, arn, and will be attached to the latest version of the function.

How to create a function URL for Lambda?

From Console, you can create a function ULR in the checking Enable Function URL option in advance settings.

You can also apply Authentication using IAM user and role. There is also an option to configure CORS, by default all origins are allowed.

CORS settings can be edited after the function is created.

After the function is created one can see the Function URL as shown below in the console.

def lambda_handler(event, context):
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')

In the above example, I created a function from scratch using python. On hitting URL you will get a response with a 200 status code.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.