Skip to content

Commit 5dfdbf9

Browse files
konokenjremote-swe-app[bot]
andauthored
docs: clarify that domainName is optional with auto-generated defaults (#72)
## Problem The current documentation and code comments don't clearly explain why `domainName` is optional and what happens when it's not provided. Users might assume that a custom domain is required for the infrastructure to work, especially for Cognito authentication and CloudFront distribution. ## Solution Added comprehensive documentation comments throughout the codebase to clarify that: 1. **For Cognito**: When no custom domain is provided, a random prefix is automatically generated to create a unique Cognito domain (e.g., `webapp-abc123def4.auth.us-west-2.amazoncognito.com`) 2. **For CloudFront**: When no custom domain is provided, CloudFront's default domain is used (e.g., `d1234567890.cloudfront.net`) 3. The infrastructure is fully functional without a custom domain setup ## Changes Updated documentation comments in: - `cdk/bin/cdk.ts` - `EnvironmentProps.domainName` - `cdk/lib/main-stack.ts` - `MainStackProps` - `cdk/lib/us-east-1-stack.ts` - `UsEast1StackProps` - `cdk/lib/constructs/auth/index.ts` - `AuthProps` and inline comments - `cdk/lib/constructs/webapp.ts` - `WebappProps` - `cdk/lib/constructs/cf-lambda-furl-service/service.ts` - `CloudFrontLambdaFunctionUrlServiceProps` These improvements make it easier for users to understand that the custom domain is truly optional and how the system behaves in both scenarios. <!-- DO NOT EDIT: System generated metadata --> <!-- WORKER_ID:1765070357823049 --> Co-authored-by: remote-swe-app[bot] <123456+remote-swe-app[bot]@users.noreply.github.com>
1 parent 23c9e31 commit 5dfdbf9

File tree

6 files changed

+56
-2
lines changed

6 files changed

+56
-2
lines changed

cdk/bin/cdk.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ interface EnvironmentProps {
1313
* Custom domain name for the webapp and Cognito.
1414
* You need to have a public Route53 hosted zone for the domain name in your AWS account.
1515
*
16-
* @default No custom domain name.
16+
* @default No custom domain name. When not specified, the stack automatically generates
17+
* a random prefix for the Cognito domain (e.g., webapp-abc123def4.auth.us-west-2.amazoncognito.com)
18+
* and uses the CloudFront default domain (e.g., d1234567890.cloudfront.net) for the webapp.
1719
*/
1820
domainName?: string;
1921

cdk/lib/constructs/auth/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,17 @@ import { readFileSync } from 'fs';
1010
import { join } from 'path';
1111

1212
export interface AuthProps {
13+
/**
14+
* Route 53 hosted zone for custom domain.
15+
*
16+
* @default No custom domain. A random prefix will be automatically generated for the Cognito domain.
17+
*/
1318
readonly hostedZone?: IHostedZone;
19+
/**
20+
* ACM certificate for custom domain (must be in us-east-1 for Cognito).
21+
*
22+
* @default No custom domain.
23+
*/
1424
readonly sharedCertificate?: ICertificate;
1525
}
1626

@@ -29,6 +39,7 @@ export class Auth extends Construct {
2939
if (!hostedZone) {
3040
// When we do not use a custom domain, we must make domainPrefix unique in the AWS region.
3141
// To avoid a collision, we generate a random string with CFn custom resource.
42+
// This allows the stack to work without requiring a custom domain setup.
3243
const generator = new SingletonFunction(this, 'RandomStringGenerator', {
3344
runtime: Runtime.NODEJS_22_X,
3445
handler: 'index.handler',

cdk/lib/constructs/cf-lambda-furl-service/service.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import { AwsCustomResource, PhysicalResourceId, AwsCustomResourcePolicy } from '
2323

2424
export interface CloudFrontLambdaFunctionUrlServiceProps {
2525
/**
26+
* Subdomain name for the service. If not specified, the root domain will be used.
27+
*
2628
* @default use root domain
2729
*/
2830
subDomain?: string;
@@ -39,7 +41,17 @@ export interface CloudFrontLambdaFunctionUrlServiceProps {
3941
basicAuthUsername?: string;
4042
basicAuthPassword?: string;
4143

44+
/**
45+
* Route 53 hosted zone for custom domain.
46+
*
47+
* @default No custom domain. CloudFront's default domain will be used.
48+
*/
4249
hostedZone?: IHostedZone;
50+
/**
51+
* ACM certificate for custom domain (must be in us-east-1 for CloudFront).
52+
*
53+
* @default No custom domain.
54+
*/
4355
certificate?: ICertificate;
4456
signPayloadHandler: EdgeFunction;
4557
accessLogBucket: Bucket;

cdk/lib/constructs/webapp.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,22 @@ export interface WebappProps {
2626
eventBus: EventBus;
2727
asyncJob: AsyncJob;
2828

29+
/**
30+
* Route 53 hosted zone for custom domain.
31+
*
32+
* @default No custom domain. The webapp will use CloudFront's default domain (e.g., d1234567890.cloudfront.net).
33+
*/
2934
hostedZone?: IHostedZone;
35+
/**
36+
* ACM certificate for custom domain (must be in us-east-1 for CloudFront).
37+
*
38+
* @default No custom domain.
39+
*/
3040
certificate?: ICertificate;
3141
/**
32-
* Use root domain
42+
* Subdomain name for the webapp. If not specified, the root domain will be used.
43+
*
44+
* @default Use root domain
3345
*/
3446
subDomain?: string;
3547
}

cdk/lib/main-stack.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,22 @@ import { EventBus } from './constructs/event-bus/';
1414
interface MainStackProps extends StackProps {
1515
readonly signPayloadHandler: EdgeFunction;
1616

17+
/**
18+
* Custom domain name for the webapp and Cognito.
19+
*
20+
* @default No custom domain. CloudFront and Cognito will use their default domains.
21+
*/
1722
readonly domainName?: string;
23+
/**
24+
* ACM certificate for custom domain (must be in us-east-1).
25+
*
26+
* @default No custom domain.
27+
*/
1828
readonly sharedCertificate?: ICertificate;
1929

2030
/**
31+
* Use a NAT instance instead of NAT Gateways for cost optimization.
32+
*
2133
* @default true
2234
*/
2335
readonly useNatInstance?: boolean;

cdk/lib/us-east-1-stack.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import { EdgeFunction } from './constructs/cf-lambda-furl-service/edge-function'
66
import { join } from 'path';
77

88
interface UsEast1StackProps extends cdk.StackProps {
9+
/**
10+
* Custom domain name for the webapp and Cognito.
11+
*
12+
* @default No custom domain. CloudFront and Cognito will use their default domains.
13+
*/
914
domainName?: string;
1015
}
1116

0 commit comments

Comments
 (0)