Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/cdk/src/methods/fargate.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -39,6 +40,7 @@ export enum ServiceMemoryLimit {
export interface AddServiceOptions {
architecture?: CpuArchitecture;
assignPublicIp?: boolean;
awsLogs?: Partial<AwsLogDriverProps>;
baseDir: string;
certificateArn: string;
command?: string[];
Expand Down Expand Up @@ -70,6 +72,7 @@ export const addFargateService = (options: AddServiceOptions): AddServiceResult
const {
architecture = CpuArchitecture.ARM64,
assignPublicIp = true,
awsLogs,
baseDir,
certificateArn,
command,
Expand Down Expand Up @@ -134,8 +137,11 @@ export const addFargateService = (options: AddServiceOptions): AddServiceResult
family: `${serviceName}-task-def`,
image,
logDriver: LogDriver.awsLogs({
logRetention: RetentionDays.ONE_WEEK,
streamPrefix: serviceName
streamPrefix: serviceName,
// 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
Expand Down
Loading