Are there any problems with this AWS architecture proposal? │ │ Network Load Balancer…
- User
Are there any problems with this AWS architecture proposal?
│ │ Network Load Balancer Implementation Plan for DCV WebSocket Connections │ │ │ │ │ │ │ │ Current Architecture Overview │ │ │ │ │ │ │ │ - Environment tasks are created dynamically by the orchestration service │ │ │ │ - Each task runs DCV server on port 8443 with self-signed certificates │ │ │ │ - Frontend connects directly to task public IPs: https://{public_ip}:8443 │ │ │ │ - Current setup causes browser certificate warnings │ │ │ │ │ │ │ │ Proposed Solution: NLB with SSL/TLS Termination │ │ │ │ │ │ │ │ 1. Create Network Load Balancer Infrastructure │ │ │ │ │ │ │ │ - File: computer_use_aws/constructs/load_balancing.py │ │ │ │ - Add new NetworkLoadBalancerConstruct class │ │ │ │ - Configure NLB for TCP traffic on port 8443 │ │ │ │ - Enable cross-zone load balancing for better distribution │ │ │ │ - Create target group for environment tasks │ │ │ │ │ │ │ │ 2. Implement SSL/TLS Certificate Management │ │ │ │ │ │ │ │ - File: computer_use_aws/constructs/security.py │ │ │ │ - Add ACM certificate request for NLB domain │ │ │ │ - Use DNS validation (preferred) or email validation │ │ │ │ - Certificate will validate *.elb.amazonaws.com domain │ │ │ │ │ │ │ │ 3. Configure NLB Listener with TLS │ │ │ │ │ │ │ │ - File: computer_use_aws/constructs/load_balancing.py │ │ │ │ - Add TLS listener on port 8443 │ │ │ │ - Configure SSL policy for WebSocket compatibility │ │ │ │ - Set backend protocol to TCP (pass-through to DCV) │ │ │ │ │ │ │ │ 4. Dynamic Target Registration │ │ │ │ │ │ │ │ - File: computer_use_aws/constructs/serverless.py │ │ │ │ - Create Lambda function to register/deregister ECS tasks │ │ │ │ - Trigger on ECS task state changes (EventBridge) │ │ │ │ - Register tasks with private IPs to NLB target group │ │ │ │ │ │ │ │ 5. Update Security Groups │ │ │ │ │ │ │ │ - File: computer_use_aws/constructs/security.py │ │ │ │ - Add NLB security group │ │ │ │ - Allow inbound 8443 from anywhere to NLB │ │ │ │ - Update environment SG to allow 8443 from NLB only │ │ │ │ - Remove direct public access to environment tasks │ │ │ │ │ │ │ │ 6. Modify Task Configuration │ │ │ │ │ │ │ │ - File: computer_use_aws/stacks/container_stack.py │ │ │ │ - Remove assignPublicIp: 'ENABLED' from environment tasks │ │ │ │ - Tasks will use private IPs only │ │ │ │ - Configure health checks for target group │ │ │ │ │ │ │ │ 7. Update Frontend Connection Logic │ │ │ │ │ │ │ │ - File: computer_use_aws/frontend/src/TabContainer.tsx │ │ │ │ - Change from https://{public_ip}:8443 to NLB endpoint │ │ │ │ - Use NLB DNS name with proper SSL certificate │ │ │ │ - Update connection URL pattern │ │ │ │ │ │ │ │ 8. Add NLB Outputs │ │ │ │ │ │ │ │ - File: computer_use_aws/stacks/main_stack.py │ │ │ │ - Output NLB DNS name │ │ │ │ - Output NLB ARN for monitoring │ │ │ │ - Add instructions for DNS alias if custom domain needed │ │ │ │ │ │ │ │ Benefits │ │ │ │ │ │ │ │ 1. Valid SSL Certificate: Browser trusts ELB certificate │ │ │ │ 2. Simplified Access: Single endpoint for all DCV connections │ │ │ │ 3. Better Security: Environment tasks not directly exposed │ │ │ │ 4. Scalability: NLB handles load distribution automatically │ │ │ │ 5. Health Monitoring: Built-in health checks for targets │ │ │ │ │ │ │ │ Implementation Order │ │ │ │ │ │ │ │ 1. Create NLB and certificate infrastructure │ │ │ │ 2. Set up Lambda for dynamic target registration │ │ │ │ 3. Update security groups │ │ │ │ 4. Modify ECS task configuration │ │ │ │ 5. Update frontend to use NLB endpoint │ │ │ │ 6. Test end-to-end connectivity │ │ │ │ │ │ │ │ Notes │ │ │ │ │ │ │ │ - NLB preserves WebSocket connections (Layer 4) │ │ │ │ - TLS termination at NLB, then TCP to backend │ │ │ │ - Backend DCV self-signed certs remain unchanged │ │ │ │ - Consider using custom domain with Route53 alias
Assistant
Your AWS architecture proposal for using a Network Load Balancer (NLB) with TLS termination to handle DCV WebSocket connections is well-structured and addresses the core issues of security, scalability, and reliability. However, there are several potential concerns and improvements worth considering before finalizing this design.
✅ Strengths of the Proposal
Before diving into the issues, let's acknowledge what’s working well:
- Use of NLB: Appropriate for TCP-based WebSockets; preserves client IPs and offers low latency.
- TLS Termination at NLB: Solves browser certificate warnings by offloading SSL/TLS from backend tasks.
- Dynamic Target Registration via Lambda: Enables auto-scaling and dynamic task management.
- Removal of Public IPs from Tasks: Improves security posture by reducing attack surface.
- Security Group Hardening: Restricts direct access to environment tasks.
❗Potential Issues & Recommendations
1. ACM Certificate Domain Limitation
You're requesting an ACM certificate for
*.elb.amazonaws.com.🚨 Issue:
- AWS does not allow you to request public certificates for domains like
*.elb.amazonaws.comunless you own that domain. - This will fail in practice because only AWS owns
elb.amazonaws.com.
✅ Recommendation:
- If you're exposing the service externally with a custom domain, request the certificate for your own domain (e.g.,
dcv.example.com) or wildcard (*.example.com). - Use Route 53 DNS validation if possible.
- If no custom domain is used, you'll need to either:
- Accept the fact that the frontend will connect via the NLB DNS name (which doesn’t have a valid cert in browsers).
- Use a reverse proxy (e.g., Nginx on EC2 or ALB) in front of NLB to terminate TLS with a valid cert.
2. WebSocket Support in NLB
"Notes: NLB preserves WebSocket connections (Layer 4)"
✅ Correct, but...
- NLB operates at Layer 4 and supports long-lived TCP connections including WebSockets.
- But no idle timeout customization beyond 350s (default is 350s).
- WebSocket connections may be dropped if idle longer than this.
✅ Recommendation:
- Ensure your DCV application includes keep-alive messages to avoid idle timeouts.
- Alternatively, consider Application Load Balancer (ALB) if you don't strictly require Layer 4 behavior (ALB supports WebSockets with HTTP/1.1 Upgrade).
3. Health Checks Configuration
"Configure health checks for target group"
🚨 Missing Details
- The health check implementation details are missing.
- If DCV servers do not expose a
/healthendpoint, the default health check might fail.
✅ Recommendation:
- Define expected health check path, port, timeout, interval, and success threshold.
- If DCV does not support a standard health endpoint, consider deploying a sidecar container or script to respond to health checks.
4. Target Registration: Private IPs Only
"Register tasks with private IPs to NLB target group"
✅ Good approach — but ensure:
- NLB and ECS tasks are in the same VPC.
- If using multiple subnets, make sure NLB has listeners in all required zones (cross-zone load balancing enabled as mentioned).
5. DNS Propagation Delay in Frontend
Frontend changes to use NLB DNS name
🚨 Potential issue:
- The NLB DNS name resolves to IP addresses via AWS-controlled DNS — which can take up to 60 seconds to propagate after updates.
- Frontend clients may experience brief connection issues during scaling events or NLB reconfiguration.
✅ Recommendation:
- Implement client-side retry logic with exponential backoff.
- Consider caching the NLB DNS resolution on the backend/frontend if applicable.
6. Custom Domain + Route 53 Alias
Note mentions custom domain with Route 53 alias
✅ Implementation Tip:
- When using a custom domain, create a Route 53 A record with alias pointing to the NLB.
- This ensures DNS performance and avoids TTL-related issues.
7. SSL Policy Compatibility for WebSocket
"Configure SSL policy for WebSocket compatibility"
🚨 Suggestion:
- Explicitly define which SSL policies are acceptable (e.g.,
ELBSecurityPolicy-TLS-1-2-Ext2020-06). - Older SSL policies may cause handshake failures depending on client browser/device support.
8. Monitoring & Logging
Not explicitly included in the plan
✅ Recommendation:
- Enable NLB access logs (to S3) for auditing and troubleshooting.
- Add CloudWatch metrics alarms for unhealthy hosts, high error rates, etc.
- Instrument Lambda function (target registration) with CloudWatch Logs and X-Ray tracing.
9. Lambda Function Reliability
Lambda triggered by EventBridge on ECS state change
✅ Best Practice:
- Ensure the Lambda function is idempotent and handles duplicate events gracefully.
- Set up retries and dead-letter queues (DLQs) for failed invocations.
- Monitor Lambda errors and duration metrics.
🧩 Optional Enhancements
Enhancement Benefit Use of AWS WAF with custom domain Protect against abuse/DDoS Stickiness (if needed) For session affinity (though WebSockets usually keep connection open) Auto Scaling for environment tasks To pair with dynamic NLB targets
🔍 Summary Table
Area Status Notes NLB Use ✅ Good choice Layer 4 handling for WebSockets ACM Certificate ❌ Incorrect domain Can't request *.elb.amazonaws.com TLS Config ✅ Specify SSL policy WebSocket Timeout ⚠️ Consider Idle timeout at 350s Health Checks ⚠️ Needs detail Must match DCV health endpoint Task Reg. Lambda ✅ Add DLQ and monitoring Security Groups ✅ Tightened access Custom Domain ⚠️ Partially covered Needs Route 53 + cert Monitoring ⚠️ Missing Add logging/metrics
✅ Final Thoughts
Overall, this is a solid architectural proposal that improves security and manageability. Just be careful around:
- Certificate issuance for the right domain (not elb.amazonaws.com).
- WebSocket idle timeout handling.
- Health check configuration matching DCV behavior.
- Frontend resilience to DNS/IP changes.
With these considerations addressed, this solution should scale well and provide a seamless, secure user experience for DCV WebSocket connections.
Would you like a sample CDK code snippet for any part of this setup?
- User
Does ELB have ssl termination or provide a trusted certificate for this kind of router/reverse proxy use case by default without ACM?
Assistant
Great question! Let's break this down clearly:
❓Does ELB (Elastic Load Balancing) provide SSL/TLS termination with a trusted certificate by default without using ACM?
✅ Short Answer:
No, AWS Elastic Load Balancers (NLB or ALB) do not provide a trusted SSL/TLS certificate by default. You must explicitly associate an SSL/TLS certificate from AWS Certificate Manager (ACM) to enable HTTPS/SSL termination.
🔍 Detailed Breakdown
There are two main types of AWS load balancers relevant here:
Type Layer Supports TLS Termination Trusted Cert by Default? Requires ACM? Application Load Balancer (ALB) Layer 7 (HTTP/HTTPS) ✅ Yes ❌ No ✅ Yes Network Load Balancer (NLB) Layer 4 (TCP/TLS) ✅ Yes (TLS passthrough or termination) ❌ No ✅ Yes for TLS termination
🧾 How TLS Termination Works on ELBs
To enable trusted SSL/TLS termination, you need to:
- Request or import a certificate in ACM (e.g.,
yourdomain.comor*.yourdomain.com) - Attach the certificate to your ALB or NLB listener
- Configure the listener to use:
- HTTPS (for ALB)
- TLS (for NLB)
Then, the load balancer will handle the SSL handshake and forward decrypted traffic (or re-encrypted) to backend targets.
🚫 What You Can't Do
You cannot get a trusted SSL certificate automatically for:
- The default DNS name of the load balancer (
*.elb.amazonaws.com) - Unless you own that domain (you don’t), ACM won’t issue a cert for it
So if you try to access your service via the NLB DNS name like:
my-nlb-1234567890.us-east-1.elb.amazonaws.com…you’ll still see browser certificate warnings, unless you install a custom cert via ACM for a domain you control.
✅ Workarounds If You Don’t Want to Use a Custom Domain
If you don’t have a custom domain but want to avoid browser certificate warnings:
Option 1: Use an Application Load Balancer + Self-signed Proxy (Not Recommended)
- Place an ALB in front of your NLB or backend.
- Use a self-signed cert on the backend, and terminate TLS at the ALB.
- But again, you still need a valid cert on the ALB (from ACM) to avoid browser warnings.
Option 2: Use a Reverse Proxy (EC2/Nginx with Let’s Encrypt)
- Deploy a reverse proxy (e.g., Nginx on EC2 or ECS) in front of your NLB.
- Use Let’s Encrypt or another provider to get a free cert.
- This allows more flexibility than NLB-only setups.
- Downside: Adds operational overhead.
Option 3: Use a Custom Domain + Route 53 + ACM (Recommended)
- Register a domain (via Route 53 or elsewhere).
- Request a public certificate in ACM for that domain.
- Point a DNS record (A or CNAME) to your NLB or ALB.
- This is the standard AWS-recommended way to expose services securely.
🛡️ Summary
Question Answer Does ELB come with a trusted certificate by default? ❌ No Can I use TLS termination on ELB without ACM? ❌ No — you must use ACM to attach a certificate Can I use a cert for *.elb.amazonaws.com?❌ No — you can't request certs for domains you don't own Best solution for trusted SSL termination? ✅ Use ACM with a custom domain
✅ Recommendation
If you're exposing this service to end users (e.g., browsers), always:
- Use a custom domain (e.g.,
dcv.example.com) - Request a public certificate in ACM for that domain
- Attach it to your NLB or ALB listener
- Use Route 53 alias records to point the domain to the load balancer
This gives you full trust without certificate warnings.
Would you like a sample CDK or Terraform snippet showing how to set up ACM + NLB with TLS termination?
- Request or import a certificate in ACM (e.g.,
- User
Can I layer cloud front in front of an NLB, then route to a number of ECS tasks running DCV behind that?
Assistant
Yes, you can layer Amazon CloudFront in front of an NLB, and route traffic to a number of ECS tasks running DCV behind it — but there are important considerations depending on your use case (especially for WebSocket connections like DCV).
Let’s walk through this architecture carefully.
✅ TL;DR: Yes, You Can Use CloudFront + NLB + ECS/DCV
But:
- CloudFront supports WebSockets, but only when used with an Application Load Balancer (ALB) or custom origin using HTTP/HTTPS.
- CloudFront does not support raw TCP (used by NLB), so NLB cannot be a direct origin for CloudFront.
So, if you want to use CloudFront in front of DCV, here's what works:
🧩 Recommended Architecture
User Browser ↓ CloudFront (HTTPS) ↓ Application Load Balancer (ALB) – TLS termination ↓ ECS Tasks (running DCV) – private VPC❌ Not recommended:
CloudFront → NLB → ECS– doesn't work due to lack of TCP support in CloudFront.
🚫 Why You Can’t Put CloudFront Directly in Front of NLB
Feature CloudFront Limitation Protocols Supported Only HTTP/HTTPS (no raw TCP or UDP) Origin Types S3, HTTP(S) Custom Origins (e.g., ALB, EC2, etc.), Lambda@Edge WebSocket Support ✅ via HTTP Upgrade over HTTPS TLS Termination ✅ at CloudFront edge locations → Since NLB operates at Layer 4 (TCP) and does not speak HTTP, CloudFront cannot talk directly to NLB.
✅ How to Add CloudFront for DCV WebSocket Traffic
Option A: Use ALB Instead of NLB (Recommended)
✅ Benefits:
- ALB supports HTTP/1.1 and WebSocket upgrades
- Works natively with CloudFront
- Supports ACM certificates directly
- Can integrate with ECS service discovery
🔁 Updated Architecture:
User Browser ↓ CloudFront (HTTPS) – CDN + caching + WAF ↓ Application Load Balancer (HTTPS) – TLS termination ↓ ECS Tasks (running DCV) – private VPC📝 Notes:
- Ensure ALB listener uses the correct HTTP/HTTPS rules to allow WebSocket upgrade headers.
- Set appropriate idle timeouts (WebSockets can stay open for hours).
- Use sticky sessions if needed (not usually required for DCV).
- Use ACM certificate on ALB (or CloudFront if desired).
Option B: Use CloudFront + Custom Proxy (Advanced)
If you really need NLB behavior (e.g., static IP, Layer 4 passthrough), you can do this:
User Browser ↓ CloudFront (HTTPS) – terminates TLS ↓ EC2/Nginx/Traefik reverse proxy (in VPC) ↓ Network Load Balancer (NLB) – Layer 4 TCP ↓ ECS Tasks (running DCV)📝 Notes:
- The reverse proxy handles TLS from CloudFront and forwards raw TCP to NLB.
- This adds operational overhead but gives full flexibility.
- Useful if you must preserve source IPs or require TCP-level routing.
⚠️ Considerations for DCV + WebSockets
Concern Solution Long-lived connections Increase idle timeout (default is 60s for ALB) Upgrade headers Ensure ALB allows Upgrade: websocketheaderClient IP visibility Use ALB proxy protocol or CloudFront custom headers Security Use ACM cert + WAF on CloudFront Caching Disable caching for WebSocket paths
✅ When to Use CloudFront in This Scenario
Use CloudFront if you want one or more of the following:
- Global low-latency access (CloudFront edge locations)
- DDoS protection (via AWS Shield)
- WAF integration
- Custom domain SSL management
- Caching (for non-WebSocket parts of your app)
- Custom error responses
🧪 Sample ALB Listener Rule for WebSockets
Ensure your ALB allows the
Upgradeheader:GET /websocket-path HTTP/1.1 Upgrade: websocket Connection: UpgradeIn CDK or Terraform, make sure the ALB listener allows these headers.
✅ Summary Table
Component Supported? Notes CloudFront → NLB ❌ No CloudFront only supports HTTP/S origins CloudFront → ALB → ECS ✅ Yes Best practice for WebSockets CloudFront → Reverse Proxy → NLB → ECS ✅ Yes Flexible but complex WebSockets over CloudFront ✅ Yes With ALB or reverse proxy TLS Termination ✅ Yes On CloudFront or ALB
🛠 Want a CDK or Terraform Example?
I can provide a working example using:
- CloudFront
- ALB
- ACM Certificate
- ECS Tasks with DCV
- WebSocket-friendly configuration
Just let me know which tool (CDK or Terraform) you're using!
Would you like help building this out?
- User
I'm setting up a demo for this and it's fine to go create a domain name. But I need the domain to be dynamically generated so any random person spinning this demo up via CDK in their account can get a new domain name that isn't already used. How do I do this in AWS?
Assistant
Great question — you're building a self-contained AWS CDK demo where:
- Each user spins up their own copy of the infrastructure.
- You need a unique domain name per deployment, so it doesn’t clash with others’ demos.
- The domain must be dynamically generated (e.g.,
demo-123456789.example.com). - You want to use ACM for SSL/TLS termination.
✅ Goal
Automate generation of:
- A unique subdomain per CDK deployment (e.g.,
demo-<random-id>.example.com) - An ACM certificate for that domain
- A Route 53 DNS record pointing to your load balancer
🧩 Solution Overview
You can achieve this by:
1. Generate a Random ID or Use Stack Name
Use the CDK stack name or generate a random suffix to make each domain unique.
const suffix = Names.uniqueId(this).toLowerCase(); // e.g., "a1b2c3d4" const subdomain = `demo-${suffix}`; const fullDomain = `${subdomain}.example.com`;Note:
Names.uniqueId()is a CDK utility that generates a short, deterministic ID based on the stack and construct path.
2. Request an ACM Certificate Dynamically
Use the
DnsValidatedCertificateconstruct from the@aws-cdk/aws-certificatemanager-alphapackage.This automatically validates your domain using Route 53 DNS records.
Example:
import * as acm from 'aws-cdk-lib/aws-certificatemanager'; import * as route53 from 'aws-cdk-lib/aws-route53'; import { DnsValidatedCertificate } from '@aws-cdk/aws-certificatemanager-alpha'; const zone = route53.HostedZone.fromLookup(this, 'Zone', { domainName: 'example.com', }); const certificate = new DnsValidatedCertificate(this, 'DemoCertificate', { domainName: fullDomain, hostedZone: zone, region: 'us-east-1', // required for global CloudFront or ALB });
3. Create a Route 53 Record Dynamically
If you’re deploying a load balancer (NLB or ALB), create a DNS A record in Route 53.
Example:
import * as elbv2 from 'aws-cdk-lib/aws-elasticloadbalancingv2'; // Assume you have an Application Load Balancer already created const alb = new elbv2.ApplicationLoadBalancer(this, 'ALB', { vpc, internetFacing: true, }); new route53.ARecord(this, 'AliasRecord', { zone, target: route53.RecordTarget.fromAlias(new targets.LoadBalancerTarget(alb)), recordName: subdomain, });Now, each time someone runs
cdk deploy, they get:- A unique subdomain like
demo-a1b2c3d4.example.com - A valid ACM cert for that domain
- A Route 53 A record pointing to the ALB/NLB
🔁 Full End-to-End Flow
User runs cdk deploy ↓ CDK generates unique subdomain: demo-a1b2c3d4.example.com ↓ Deploys Route 53 Hosted Zone (if not exists) + A record ↓ Requests ACM cert with DNS validation via Route 53 ↓ Deploys ALB or NLB + ECS tasks ↓ Users access via https://demo-a1b2c3d4.example.com
⚠️ Requirements
To make this work:
1. Hosted Zone Already Exists
You must own or import the parent domain (
example.com) into Route 53.- You can either:
- Buy the domain via Route 53
- Import an existing domain from another registrar
2. Permissions
Ensure your CDK IAM role has permissions to:
- Modify Route 53 records
- Request ACM certificates
- Create/load ALB/NLB
🧪 Bonus: Make It Fully Self-contained (Optional)
If you want zero manual setup, you could also:
Option A: Use a Fixed Subdomain Pattern with Wildcard Cert
- Use a shared domain (e.g.,
yourcompany-demo.com) - Issue a wildcard cert:
*.yourcompany-demo.com - Each user gets a sub-subdomain like
demo-a1b2c3d4.yourcompany-demo.com - No need to issue new certs every time
This avoids needing to request a new ACM cert per deployment.
Option B: Generate a Random Domain Using AWS Secrets Manager
You could write a custom resource Lambda that:
- Generates a random domain like
demo-randomstring123.com - Registers it via Route 53
- Issues a cert
But this adds complexity and cost unless needed.
✅ Final Recommendation
For simplicity and reusability, go with:
const suffix = Names.uniqueId(this).toLowerCase(); const fullDomain = `demo-${suffix}.example.com`;And use:
- Route 53 for DNS
- ACM +
DnsValidatedCertificatefor TLS - ALB or NLB + CloudFront if needed
Each user gets a unique, trusted domain when they run
cdk deploy.
🛠 Want a Working CDK Template?
I can provide a complete CDK app template that includes:
- Unique domain generation
- ACM cert
- ALB + ECS task
- Route 53 DNS entry
Let me know which language you're using:
- TypeScript
- Python
- Java
- C#
And I’ll give you a ready-to-deploy demo!
- User
But you've already said that "Use “no custom domain” and just eat the AWS load-balancer (or CloudFront) DNS name" that I can't get that DNS name to ssl terminate?
Assistant
You're absolutely right to call this out — and you're asking a very important architectural question that often trips people up when building demos or multi-tenant deployments on AWS.
Let’s clarify the core issue:
🔁 Recap of Your Question
You previously said I can't get a trusted certificate for the default ELB DNS name (like
my-nlb-1234567890.us-east-1.elb.amazonaws.com) unless I own that domain.So if I don’t want to use a custom domain (e.g.,
example.com), is there any way to get a trusted SSL certificate for the load balancer's auto-generated DNS name?
✅ Short Answer:
❌ No, you cannot get a trusted SSL/TLS certificate for the default AWS NLB/ALB DNS name (
*.elb.amazonaws.com) unless you own that domain, which you don't.And therefore:
You cannot do TLS termination with a trusted certificate on the default NLB/ALB DNS name without your own ACM certificate.
So trying to access it via HTTPS in a browser will result in:
NET::ERR_CERT_AUTHORITY_INVALIDEven though the connection is encrypted, the browser doesn't trust the cert because it's issued to
*.elb.amazonaws.com, and the cert is self-signed by AWS (not publicly trusted).
🧠 Let’s Clarify Why That Happens
1. Default NLB/ALB DNS Name
Looks like:
my-loadbalancer-1234567890.us-east-1.elb.amazonaws.comAWS gives this to you automatically when you create a load balancer.
But this is not a public-facing endpoint with a trusted cert unless you explicitly configure one.
2. TLS Termination Requires a Certificate from ACM
To make a load balancer support HTTPS or TLS termination with a trusted cert, you must attach a certificate from ACM.
- ACM only allows you to request certificates for domains you control.
- You cannot request a certificate for
*.elb.amazonaws.com.
So this fails:
new acm.Certificate(this, 'ElbDomainCert', { domainName: '*.elb.amazonaws.com', validation: acm.CertificateValidation.fromDns(zone), });AWS will reject it.
🚫 What About Just Using HTTPS with the Default Cert?
If you try to connect via HTTPS using the NLB DNS name:
https://my-loadbalancer-1234567890.us-east-1.elb.amazonaws.com…you’ll see a certificate warning because:
- The cert is self-signed by AWS.
- It’s not trusted by browsers or most clients.
- It’s only valid for internal AWS communication (if at all).
✅ So What Are My Options If I Don’t Want to Use a Custom Domain?
You have a few paths depending on your use case.
✅ Option 1: Use ALB + CloudFront with a Wildcard ACM Certificate (Best for Demos)
If you're deploying a demo for multiple users, and you own a domain, say
demo.example.com, then:Architecture:
User Browser ↓ CloudFront (https://random123.demo.example.com) ↓ ALB (no public cert needed) ↓ ECS Tasks (DCV)How it works:
- Use CDK to generate a unique subdomain per deployment: e.g.,
random123.demo.example.com - Request an ACM cert for
*.demo.example.comonce - Deploy CloudFront distributions with that domain
- Each user gets their own CloudFront URL with a trusted cert
This avoids having to reissue certs every time someone runs
cdk deploy.
✅ Option 2: Use Self-Signed Certs but Bypass Browser Security (for Internal Testing Only)
If you're just testing internally:
For browser:
- Manually accept the certificate warning (one-time).
- Or install the self-signed cert as trusted on your OS/browser.
For API/cli tools:
- Use
--insecureor equivalent flag to bypass cert validation.
⚠️ This is not safe for production or external demos.
✅ Option 3: Use a Reverse Proxy with Let’s Encrypt (Advanced)
Set up a reverse proxy (e.g., Nginx) in front of your NLB with Let’s Encrypt:
User → https://demo-randomstring.example.com → EC2/Nginx (Let’s Encrypt cert) → NLB → DCV Task- You dynamically generate a domain per deployment
- Automatically request a Let’s Encrypt cert using something like Certbot
This works well but adds complexity and requires more automation (DNS hooks, etc.)
✅ Option 4: Use HTTP Instead of HTTPS (Not Recommended)
If you're doing backend-to-backend communication or testing locally:
- Disable HTTPS altogether
- Use HTTP listener on ALB/NLB
But again, this won't work for browser connections due to security restrictions.
✅ Summary Table
Approach Trusted Cert? Browser Friendly? Dynamic Domains? Complexity Use default NLB DNS name ❌ Self-signed only ❌ No ⚠️ Not applicable Low Use ACM cert on ALB/NLB ✅ Yes ✅ Yes ✅ Yes (with domain) Medium CloudFront + wildcard cert ✅ Yes ✅ Yes ✅ Yes Medium-High Self-signed + manual trust ❌ Not trusted by default ⚠️ Only dev/test ⚠️ Manual steps Low Reverse proxy + Let’s Encrypt ✅ Yes ✅ Yes ✅ Yes High
✅ Final Recommendation
If you’re building a self-contained CDK demo where users spin up infrastructure in their own AWS accounts:
Best Practice:
✅ Use a shared domain (e.g.,
demo.example.com) with a wildcard cert (*.demo.example.com)Then:
- Generate dynamic subdomains per deployment:
random123.demo.example.com - Reuse the same ACM cert across all deployments
- Avoid needing to request new certs every time someone deploys
This keeps things simple, secure, and browser-friendly.
Would you like a working CDK example of this setup (with ALB + CloudFront + wildcard cert)? I can provide TypeScript or Python code!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.