feat(cdk): forward awslogs driver options on addFargateService#8
Open
hyuntony wants to merge 2 commits intoshellscape:masterfrom
Open
feat(cdk): forward awslogs driver options on addFargateService#8hyuntony wants to merge 2 commits intoshellscape:masterfrom
hyuntony wants to merge 2 commits intoshellscape:masterfrom
Conversation
Adds an `awslogs?: Partial<AwsLogDriverProps>` 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.
…p collision
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an
awslogs?: Partial<AwsLogDriverProps>option toaddFargateService. The provided options are spread into the underlyingLogDriver.awsLogs(...)call after the function-side defaults (streamPrefix: <serviceName>,logRetention: ONE_WEEK), so callers can override anything CDK exposes without losing the defaults.Motivation
Currently the only path to tune awslogs driver options (most often
mode: NON_BLOCKINGandmaxBufferSizefor high-volume Node.js services where stdout backpressure can stall the event loop — see AWS's blog post) is to reach pastaddFargateServiceand calladdPropertyOverrideon the L1CfnTaskDefinition. That's noisy, untyped, and breaks if the L2 internals change.Usage
Partial<AwsLogDriverProps>means callers can also tunemultilinePattern,datetimeFormat,logRetention, etc., or override the function-sidestreamPrefixif they really want to.Compatibility
Backwards compatible —
awslogsis optional. Existing callers see no behavior change. CDK validatesmaxBufferSizerequiresmode: NON_BLOCKINGat synth time, so misuse fails loudly.