Serverless 101: Deploying your first AWS Lambda with a Function URL

Getting started with AWS Lambda usually means wiring an event source (API Gateway, S3, or a stream) and a function. For an introductory, low-friction path to an HTTP endpoint, Lambda Function URLs give you a built-in HTTPS endpoint that calls a single Lambda function — no API Gateway required. This makes them a great first serverless project: simple to create, fast to test, and easy to understand. (aws.amazon.com)

Why choose a Function URL for your first Lambda?

Prerequisites

Quick architecture overview

When you enable a Function URL, AWS provides a stable HTTPS endpoint like: https://.lambda-url..on.aws

Invocations to that endpoint are routed directly to the specified Lambda function or alias. You still control the function’s execution role, timeout, and memory — the Function URL is simply the HTTP trigger. (docs.aws.amazon.com)

Example: Deploy a simple Node.js function and expose it with a Function URL

Below is a compact, hands-on flow you can follow in the AWS Console or replicate with the CLI.

  1. Create a function handler (index.js)
    // index.js
    exports.handler = async (event) => {
      const name = (event.queryStringParameters && event.queryStringParameters.name) || "world";
      const body = { message: `Hello, ${name}!`, received: event };
      return {
     statusCode: 200,
     headers: { "Content-Type": "application/json" },
     body: JSON.stringify(body),
      };
    };
    
  2. Zip and upload (or use the console to paste code). If using the CLI to create the function:
    zip function.zip index.js
    aws lambda create-function \
      --function-name helloFunctionUrl \
      --runtime nodejs18.x \
      --handler index.handler \
      --zip-file fileb://function.zip \
      --role arn:aws:iam::123456789012:role/lambda-exec-role
    

    (Replace the role ARN with a role that has the AWSLambdaBasicExecutionRole policy.)

  3. Add a Function URL (CLI example)
    aws lambda create-function-url-config \
      --function-name helloFunctionUrl \
      --auth-type NONE \
      --cors '{"AllowOrigins":["*"],"AllowMethods":["GET","POST"]}'
    

    This returns the function URL you can call directly. Use auth-type NONE for an open endpoint while learning; switch to AWS_IAM before production. See the AWS docs for the exact flag names and syntax in your CLI version. (docs.aws.amazon.com)

  4. Test it Open the returned URL in a browser or:
    curl "https://<url-id>.lambda-url.<region>.on.aws?name=Alice"
    

    You should get the JSON response from the Lambda handler.

Security notes

Function URLs support two authentication modes:

If you need richer authentication (OAuth, user pools, JWTs) or advanced API features (rate limiting, usage plans, custom request/response transformations), place API Gateway or CloudFront in front of the Function URL or integrate with Cognito. The AWS Compute Blog has patterns for securing Function URLs with Cognito, CloudFront, and WAF if you want to learn more about protecting public endpoints. (aws.amazon.com)

When a Function URL is the right tool — and when it isn’t

Use Function URLs when:

Avoid Function URLs if you need:

Deployment and IaC

Function URLs are supported in CloudFormation, SAM, and CDK, so you can (and should) automate deployments once you understand the manual flow. That allows repeatable environments and safer rollouts as you iterate. The official Lambda docs include CloudFormation/SAM examples for creating and configuring Function URLs. (docs.aws.amazon.com)

Practical tips for beginners

Limitations and considerations

Final thoughts

Lambda Function URLs make the first serverless HTTP experience straightforward: write a handler, enable a URL, call it. This low-friction path helps you learn the core Lambda model — event in, code runs, response out — without the additional complexity of API Gateway. Once you’re comfortable with that loop, you can explore more advanced triggers, authentication models, and infrastructure-as-code deployments to expand your serverless skillset. (docs.aws.amazon.com)