Skip to content

Add lambda-microvm-custom-domain-cdk pattern - #3292

Open
tanfrank wants to merge 3 commits into
aws-samples:mainfrom
tanfrank:lambda-microvm-custom-domain-cdk
Open

Add lambda-microvm-custom-domain-cdk pattern#3292
tanfrank wants to merge 3 commits into
aws-samples:mainfrom
tanfrank:lambda-microvm-custom-domain-cdk

Conversation

@tanfrank

@tanfrank tanfrank commented Aug 27, 2026

Copy link
Copy Markdown

Adds a new pattern: Custom domains for AWS Lambda MicroVMs with Application Load Balancer.

Each Lambda MicroVM is served under a domain you own (e.g. .microvms.example.com)
instead of the service-generated .lambda-microvm..on.aws endpoint. Built
entirely from load-balancing/networking primitives — no CloudFront and no compute in the
request path: an ALB rewrites the Host header (host-header-rewrite Transform) and forwards
to the MicroVM service over PrivateLink, with a wildcard ACM cert and Route 53 wildcard record.

Framework: AWS CDK v2 (TypeScript)
Includes: README.md, example-pattern.json, cdk.json, source, and passing tests (13/13).
The optional demo layer (single-page app + provisioning API) can be removed to deploy the
pure networking pattern.

Custom domains for AWS Lambda MicroVMs using an Application Load Balancer
Host header rewrite over PrivateLink -- no CloudFront and no compute in the
request path. Includes an optional, demo-only single-page app and provisioning
API that can be removed to deploy the pure networking pattern.

Built with AWS CDK v2 (TypeScript).
Comment thread lambda-microvm-custom-domain-cdk/README.md Outdated
Comment thread lambda-microvm-custom-domain-cdk/README.md Outdated
Comment thread lambda-microvm-custom-domain-cdk/README.md Outdated
Comment thread lambda-microvm-custom-domain-cdk/README.md Outdated
Comment thread lambda-microvm-custom-domain-cdk/README.md Outdated
Comment thread lambda-microvm-custom-domain-cdk/lib/microvm-custom-domains-stack.ts Outdated
Comment thread lambda-microvm-custom-domain-cdk/lib/microvm-custom-domains-stack.ts Outdated
Comment thread lambda-microvm-custom-domain-cdk/cdk.json Outdated
Comment thread lambda-microvm-custom-domain-cdk/lib/microvm-demo-app.ts Outdated
Comment thread lambda-microvm-custom-domain-cdk/example-pattern.json Outdated
- README: 'AWS Application Load Balancer' in title; 'Amazon CloudFront';
  link 'AWS Certificate Manager (ACM)'; 'at least' in the demo security note;
  Node.js 22+ prerequisite; copyright 2026.
- Route53 -> 'Route 53' in comments/cdk.json text (CFN type untouched).
- Demo Lambda runtime NODEJS_20_X -> NODEJS_22_X.
- Scope provisioning Lambda IAM: item-level MicroVM actions to this
  account/Region + image ARN; ListMicrovms (collection-level) stays on '*'.
- Trim example-pattern.json description to <=175 chars.
- Update IAM test assertion for the scoped policy.
@tanfrank

tanfrank commented Sep 2, 2026

Copy link
Copy Markdown
Author

Pushed a commit addressing all the feedback:

Service names qualified — Corrected Route53Route 53 throughout the stack, demo construct, tests, and comments, and tightened the pattern description to consistently use the full service names (AWS Lambda, Application Load Balancer, PrivateLink).

Lambda runtime bumped to Node 22 — The demo provisioning function moved from NODEJS_20_X to NODEJS_22_X (Node 20 is on the deprecation path).

Demo IAM scoped down — The provisioning Lambda's MicroVM permissions are now least-privilege per Lambda's actual IAM authorization model:

  • RunMicrovm, GetMicrovm, and CreateMicrovmAuthToken are authorized on the MicroVM image resource (the only MicroVM resource type that exists in the model — there is no per-MicroVM ARN), so they're now scoped to the single microvmImageArn instead of *. This also implicitly pins them to the account and Region carried in the ARN.
  • ListMicrovms is declared with no resource ARN in the authorization model, so it must remain on Resource: "*" — a narrower ARN would match nothing and deny the call. It's already implicitly account-scoped (a role only lists its own account's MicroVMs).

Unit tests were updated to assert the new policy shape (13/13 passing).

Verified end to end — Deployed the pattern to a test account and smoke-tested the full flow: demo page (HTTP 200, TLS), CORS preflight (204), POST /api/provision (launches a MicroVM + mints a JWE token), and — the core of the pattern — a request to the per-MicroVM custom domain routing through the ALB Host-header rewrite over PrivateLink to the MicroVM origin, which returned 200 pong.

@bfreiberg bfreiberg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for your contribution. Your pattern will be merged soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants