
Traditionally in AWS applications you had an API Gateway fronting your Lambda function. The REST API created by API Gateway would serve as the endpoint to invoke to access your backend Lambda Function. While there’s nothing wrong with this pattern it added some extra grunt work. For starters there were two services to deal with rather than one, meaning having to deal with timeouts and constraints of both services.
Lambda Function URLs help simplify the equation greatly. When creating a Lambda function you can now create a function URL which will serve as a HTTP endpoint for your function. You can invoke this URL directly, making it easier than ever to integrate Lambda into your applications. In this article, we’ll walk through a quick example on setting up and sending post requests to your Lambda Function URL.
NOTE: For those of you new to AWS, make sure you make an account at the following link if you want to follow along. This article will also assume basic familiarity with Python, AWS, and using an AWS SDK.
Lambda Function URL Creation
You can create Lambda Function URLs via the AWS CLI or utilizing one of the AWS SDKs, but we’ll setup everything through the Console in this article for simplicity. Go to the Lambda Console and click on "Create Function".

A default Lambda IAM execution role will be created, but if you need access to any other services make sure to create and reference an IAM role that has the necessary permissions.
A code environment is automatically built for you once you’ve created your Lambda function. If you want to install other dependencies to utilize on your Lambda function, take a look at building Custom Lambda Images.

If you click on the "Configuration" tab you can easily add a Lambda Function URL. In the configuration portion you can also manage other Lambda parameters such as environment variables you will inject into your function.


For this example, we’ll be adding no Authentication and leaving CORS unchecked. Note that this means your endpoint is publicly accessible to anyone who has your Function URL, so make sure to delete all resources if you do not want to leave them open.
After creation you’ll see your Function URL, this is the API that you can invoke.

If you click the URL with the default function, you’ll notice the same handler message on screen.

To handle POST requests, let’s put some sample Python code in the Lambda function that just returns the input we pass in.
Lambda Function URL Invocation
As per the documentation, before we get to invoking our function make sure that you have "lambda:InvokeFunctionUrl" permissions. We can now do a simple curl command to send one invocation to our function.

We can also invoke the Function URL using the Python requests library.

In the next section we’ll take a quick look at how you can also monitor and debug your Lambda functions.
How Do We Debug/Monitor Lambda Functions?
It’s unlikely you’ll invoke your Lambda function just a few times in a real-time setting. When you have hundreds to thousands of invocations you need to be able to monitor your Function’s health and performance. Let’s send a hundred requests as a sample and see how we can track our function.
If we click on the "Monitor" tab next to the "Configuration" tab we see Lambda integrates closely with CloudWatch.

If you click view logs in CloudWatch, any logging code in your Lambda function should reflect in the Log Streams.

Here we see our print statement from our lambda function captured in the CloudWatch logs. CloudWatch logs in general are a great way to quickly debug your code with many AWS services.
Lambda also sends runtime metrics that you can visualize, an example of this is the number of invocations of your function. Let’s take a look at that graph quickly to see if it reflected our 100 requests accurately.

Here we can see our invocations gradually increasing reflecting our for loop we ran. To understand more about Lambda function metrics take a look at the official documentation page here.
Conclusion & Additional Resources
GitHub – RamVegiraju/lambda-function-url: Setting up & invoking Lambda Function URLs
AWS Lambda Function URLs are a highly useful feature, and Lambda Functions in general can be used even more powerfully than before. There’s a lot more to Lambda and the possible applications you can build on it that we will explore in future articles.
Hope this article was a good primer on Lambda Function URLs, if you’re interested in further AWS services please check out this list here.
If you enjoyed this article feel free to connect with me on LinkedIn and subscribe to my Medium Newsletter. If you’re new to Medium, sign up using my Membership Referral.