Kaguei Nakueka
Kaguei Nakueka

Reputation: 1108

How can I call my AWS Lambda function URL via a custom domain?

I have created an AWS Lambda with the new function URL feature enabled.

Since the URL isn't that easy to remember, I would like to create a Route 53 alias like lambda.mywebsite.com.

There is no Route 53 alias for Lambda function URLs in the drop-down menu for aliases in Route 53.

How can I call my AWS Lambda function URL via a custom domain?

Is a CNAME record the way to go?

Upvotes: 30

Views: 24584

Answers (3)

Copy and Paste
Copy and Paste

Reputation: 526

If you use CloudFlare for your DNS services you can use Redirect Rules under the Rules tab. For simple projects the DNS management is free, and you get up to 10 free Redirect Rules.

More info here: https://developers.cloudflare.com/rules/url-forwarding/single-redirects/create-dashboard/

For my purposes in CloudFlare I set up a Static redirect to my Lambda URL provided in the AWS Console, with a 307 Status Code: enter image description here

Upvotes: 9

Ermiya Eskandary
Ermiya Eskandary

Reputation: 23602

How can I call my AWS Lambda function URL via a custom domain?

If you must use an AWS Lambda function URL, fronting it with a CloudFront distribution with your desired custom domain name is the only way currently.

There is no support currently for a Route 53 alias record, as the Host header must be set to the Lambda function URL domain. If the Host header does not exist, HTTP 400 Bad Request is returned & if it does exist but is not the correct value, HTTP 403 Forbidden is returned.

They are meant to be the simplest & fastest way to invoke your Lambda functions via a public endpoint without using other AWS services like API gateway, so a native lack of support for a custom domain name makes sense.

Upvotes: 33

reena .m
reena .m

Reputation: 139

I tried the same once lambda url feature was out. Following are the steps:

  1. Create a cloudfront distribution with lambda url as https endpoint, add the domain name in the alternate domain name field.
  2. Create a A record for the domain in Route53 and point it to the cloudfront distribution.

Note: If in case you haven't added domain certificate in step1 then the cloudfront option in step2 wont show any value to select.

Upvotes: 9

Related Questions