Custom domains for AWS Lambda MicroVMs with Application Load Balancer

Application Load Balancer → AWS Lambda MicroVMs

Serve each AWS Lambda MicroVM under a domain you own via an Application Load Balancer Host header rewrite over PrivateLink, with no CloudFront or request-path compute.

This pattern gives each AWS Lambda MicroVM a domain you own (e.g. .microvms.example.com) instead of exposing the service-generated .lambda-microvm..on.aws endpoint. It is built entirely from load-balancing and networking primitives: there is no CloudFront and no compute in the request path.
A client sends HTTPS to .microvms.example.com. Route 53 resolves a wildcard record to an Application Load Balancer, which terminates TLS with a wildcard ACM certificate. A listener rule matches the host with a regex condition, then a host-header-rewrite Transform swaps only the base-domain suffix (preserving everything ahead of it) to rewrite Host to .lambda-microvm..on.aws.
The ALB forwards to an IP target group whose targets are the private ENI IPs of a MicroVM interface VPC endpoint, reaching the MicroVM service over AWS PrivateLink. The service routes to the correct MicroVM using the rewritten Host header and enforces the JWE auth token the client supplied. Because a Transform (not a redirect) performs the rewrite, the customer's domain stays intact end to end.
CORS is handled entirely at the ALB (a 204 preflight rule plus inserted Access-Control-Allow-* response headers), so no change is required inside the MicroVM. The CDK app also includes an optional, demo-only single-page app and provisioning API that can be removed to deploy the pure networking pattern.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/lambda-microvm-custom-domain-cdk

Deploy

npm installnpx cdk deploy


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: npx cdk destroy.

Created by:

Frank Scarfo

Frank Scarfo

Frank Scarfo is a Senior Software Development Engineer at Amazon Web Services.

Follow on LinkedIn