From b2ca69851e65e5a68feef52578a3338c71ebf733 Mon Sep 17 00:00:00 2001 From: hyuntony Date: Tue, 28 Apr 2026 23:15:18 -0400 Subject: [PATCH 1/2] feat(cdk): forward awslogs driver options on addFargateService MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds an `awslogs?: Partial` option that's spread into the underlying `LogDriver.awsLogs(...)` call after the function-side defaults (streamPrefix: serviceName, logRetention: ONE_WEEK). Lets callers tune the awslogs driver — typically `mode` and `maxBufferSize` for non-blocking delivery on high-volume Node services where stdout backpressure can stall the event loop — without losing the function's defaults and without reaching past the L2 via a property override escape hatch on the task definition. --- packages/cdk/src/methods/fargate.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/cdk/src/methods/fargate.ts b/packages/cdk/src/methods/fargate.ts index 7bfa4ca..8f1ef58 100644 --- a/packages/cdk/src/methods/fargate.ts +++ b/packages/cdk/src/methods/fargate.ts @@ -1,6 +1,7 @@ import { Certificate } from 'aws-cdk-lib/aws-certificatemanager'; import { InterfaceVpcEndpointAwsService, Vpc, type IVpc } from 'aws-cdk-lib/aws-ec2'; import { + type AwsLogDriverProps, ContainerImage, CpuArchitecture, LogDriver, @@ -39,6 +40,7 @@ export enum ServiceMemoryLimit { export interface AddServiceOptions { architecture?: CpuArchitecture; assignPublicIp?: boolean; + awslogs?: Partial; baseDir: string; certificateArn: string; command?: string[]; @@ -70,6 +72,7 @@ export const addFargateService = (options: AddServiceOptions): AddServiceResult const { architecture = CpuArchitecture.ARM64, assignPublicIp = true, + awslogs, baseDir, certificateArn, command, @@ -135,7 +138,8 @@ export const addFargateService = (options: AddServiceOptions): AddServiceResult image, logDriver: LogDriver.awsLogs({ logRetention: RetentionDays.ONE_WEEK, - streamPrefix: serviceName + streamPrefix: serviceName, + ...awslogs }) }, vpc From ec70f2a97a03b9bdaa0f19fa97ab1bb927b61c58 Mon Sep 17 00:00:00 2001 From: hyuntony Date: Tue, 28 Apr 2026 23:26:43 -0400 Subject: [PATCH 2/2] =?UTF-8?q?fix(cdk):=20rename=20`awslogs`=20=E2=86=92?= =?UTF-8?q?=20`awsLogs`=20and=20avoid=20logRetention/logGroup=20collision?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two follow-ups from review feedback: - Rename `awslogs` → `awsLogs` to match the camelCase convention used by every other field in `AddServiceOptions`. - Skip the function's default `logRetention: ONE_WEEK` when the caller supplies their own `logGroup`. CDK's `AwsLogDriver` constructor throws `Cannot specify both 'logGroup' and 'logRetentionDays'` at synth time, so previously a caller passing only `{ logGroup: myGroup }` would have silently hit that validation despite reasonable intent. --- packages/cdk/src/methods/fargate.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/cdk/src/methods/fargate.ts b/packages/cdk/src/methods/fargate.ts index 8f1ef58..e5304cb 100644 --- a/packages/cdk/src/methods/fargate.ts +++ b/packages/cdk/src/methods/fargate.ts @@ -40,7 +40,7 @@ export enum ServiceMemoryLimit { export interface AddServiceOptions { architecture?: CpuArchitecture; assignPublicIp?: boolean; - awslogs?: Partial; + awsLogs?: Partial; baseDir: string; certificateArn: string; command?: string[]; @@ -72,7 +72,7 @@ export const addFargateService = (options: AddServiceOptions): AddServiceResult const { architecture = CpuArchitecture.ARM64, assignPublicIp = true, - awslogs, + awsLogs, baseDir, certificateArn, command, @@ -137,9 +137,11 @@ export const addFargateService = (options: AddServiceOptions): AddServiceResult family: `${serviceName}-task-def`, image, logDriver: LogDriver.awsLogs({ - logRetention: RetentionDays.ONE_WEEK, streamPrefix: serviceName, - ...awslogs + // CDK throws if both `logGroup` and `logRetention` are set; skip the + // default when caller supplies their own log group. + ...(!awsLogs?.logGroup && { logRetention: RetentionDays.ONE_WEEK }), + ...awsLogs }) }, vpc