Skip to content

feat: bring your own resources#216

Merged
bestickley merged 9 commits intomainfrom
feat-bring-your-own-resources
Mar 23, 2026
Merged

feat: bring your own resources#216
bestickley merged 9 commits intomainfrom
feat-bring-your-own-resources

Conversation

@bestickley
Copy link
Copy Markdown
Contributor

feat: Bring Your Own Resources
Adds first-class support for importing existing AWS resources into cdk-nextjs constructs, enabling per-branch (MR/PR) deployment patterns where shared infrastructure is created once and lightweight branch stacks reuse it.

New Props
All constructs (via NextjsBaseProps):

cacheBucket?: IBucket — skip S3 cache bucket creation
revalidationTable?: ITable — skip DynamoDB table creation
staticAssetsBucket?: IBucket — skip static assets bucket creation
Container constructs (NextjsGlobalContainers, NextjsRegionalContainers):

alb?: IApplicationLoadBalancer — import an existing ALB
ecsCluster?: ICluster — skip cluster and VPC gateway endpoint creation
removeAutoCreatedListener()
New public method on NextjsContainers that surgically removes the CloudFormation resources ApplicationLoadBalancedFargateService always creates for port 80 (CfnListener, SG ingress rule, CfnOutputs) and rebuilds the ECS service DependsOn. Required when importing an ALB that already has a listener on that port.

Type Fixes
NextjsDistributionProps.loadBalancer: ApplicationLoadBalancer → IApplicationLoadBalancer (accepts imported ALBs)
NextjsCache.revalidationTable: TableV2 → ITable (public property type)
NextjsComputeBaseProps.revalidationTable: TableV2 → ITable
NextjsPostDeployProps.revalidationTable: TableV2 → ITable
NextjsPostDeployProps.staticAssetsBucket: Bucket → IBucket
NextjsStaticAssets.bucket: Bucket → IBucket
NextjsContainers.ecsCluster: Cluster → ICluster
Internal table creation remains TableV2 (no CloudFormation resource type change for existing users).

NextjsRegionalContainers.url
Delegates to this.nextjsContainers.url which correctly resolves the DNS name for both owned and imported ALBs.

Other
Dockerfile CMD switched to exec form (CMD ["node", "server.js"]), HOSTNAME moved to ENV
README: BYO resources section with supported resources table, isolation docs, removeAutoCreatedListener() usage
Three new examples in examples/bring-your-own-resources/ (global-functions, global-containers, regional-containers) using fromLookup/fromAttributes/fromBucketName/fromTableName

@bestickley bestickley self-assigned this Mar 21, 2026
@bestickley bestickley disabled auto-merge March 23, 2026 16:22
bestickley and others added 3 commits March 23, 2026 12:34
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@bestickley bestickley merged commit 567b7cf into main Mar 23, 2026
13 checks passed
@bestickley bestickley deleted the feat-bring-your-own-resources branch March 23, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant