import * as cdk from "aws-cdk-lib"; import type * as cloudwatch from "aws-cdk-lib/aws-cloudwatch"; import * as ec2 from "aws-cdk-lib/aws-ec2"; import * as ecs from "aws-cdk-lib/aws-ecs"; import * as elb from "aws-cdk-lib/aws-elasticloadbalancingv2"; import type * as lambda from "aws-cdk-lib/aws-lambda"; import * as logs from "aws-cdk-lib/aws-logs"; import * as constructs from "constructs"; import { ServiceAlarms } from "../alarms"; import type { Parameter } from "../configure-parameters"; /** * Configure service alarms. * * Alarms are enabled by default when a config object with `alarmAction` and * `warningAction` is provided. To explicitly disable automatic alarms use * `{ enabled: false }`. */ export type ServiceAlarmsConfig = { enabled: false; } | { alarmAction: cloudwatch.IAlarmAction; warningAction: cloudwatch.IAlarmAction; loadBalancerFullName: string; /** Optional Lambda function that will receive * forwarded log events */ logHandler?: lambda.IFunction; /** * Individual alarm configuration overrides defaults. */ jsonErrorAlarm?: { /** * @default true */ enabled?: boolean; alarmDescription?: string; enableOkAlarm?: boolean; action?: cloudwatch.IAlarmAction; }; uncaughtJavaExceptionAlarm?: { /** * @default false */ enabled?: boolean; alarmDescription?: string; enableOkAlarm?: boolean; action?: cloudwatch.IAlarmAction; }; targetHealthAlarm?: { /** * @default true */ enabled?: boolean; action?: cloudwatch.IAlarmAction; period?: cdk.Duration; evaluationPeriods?: number; threshold?: number; description?: string; }; tooMany5xxResponsesFromTargetsAlarm?: { /** * @default true */ enabled?: boolean; action?: cloudwatch.IAlarmAction; period?: cdk.Duration; evaluationPeriods?: number; threshold?: number; description?: string; }; targetResponseTimeAlarm?: { /** * @default true */ enabled?: boolean; action?: cloudwatch.IAlarmAction; period?: cdk.Duration; evaluationPeriods?: number; threshold?: cdk.Duration; description?: string; }; single5xxResponseAlarm?: { /** * @default true */ enabled?: boolean; /** * An action to use for CloudWatch alarm state changes instead of the default action */ action?: cloudwatch.IAlarmAction; /** * @default 60 seconds */ period?: cdk.Duration; /** * @default 1 */ evaluationPeriods?: number; /** * @default 1 */ threshold?: number; description?: string; }; }; export interface FargateServiceProps { serviceName: string; vpc: ec2.IVpc; cluster: ecs.ICluster; desiredCount: number; ecsImage: ecs.ContainerImage; portMappings?: ecs.PortMapping[]; containerHealthCheck?: ecs.HealthCheck; /** * @default 256 */ cpu?: number; /** * @default undefined */ runtimePlatform?: ecs.RuntimePlatform; /** * @default 512 */ memoryLimitMiB?: number; /** * @default 2 weeks */ logsRetention?: logs.RetentionDays; /** * @default AwsLogDriverMode.BLOCKING */ logDriverMode?: ecs.AwsLogDriverMode; /** * @default 15 seconds */ deregistrationDelay?: cdk.Duration; /** * @default 8080 */ containerPort?: number; /** * @default 60 seconds */ healthCheckGracePeriod?: cdk.Duration; /** * Use this as workaround when adding the service to a load balancer after * it has been created. For avoiding 'Health check grace period is only valid for services configured to use load balancers' * Link to GitHub issue: https://github.com/aws/aws-cdk/issues/19842 */ skipHealthCheckGracePeriod?: boolean; parameters?: Parameter[]; overrideFargateServiceProps?: Partial; overrideHealthCheck?: Partial; overrideTargetGroupProps?: Partial; overrideContainerProps?: Partial; secrets?: Record; environment?: Record; /** * @default false */ skipTargetGroup?: boolean; /** * @default false */ enableCircuitBreaker?: boolean; /** * Either * - `{ enabled: false }` to disable all alarms. * - object with required `alarmAction`, `warningAction`, and `loadBalancerFullName`. * * When enabled, the construct will: * - (By default) add a log-based JSON error alarm (enabled by default). * - (By default) add target-group related alarms (target health, 5xx responses, response time) * when a target group is present. * - (Opt-in) optionally enable the uncaught Java exception alarm */ alarms: ServiceAlarmsConfig; } export declare class FargateService extends constructs.Construct { readonly fargateService: ecs.FargateService; readonly securityGroup: ec2.SecurityGroup; readonly taskDefinition: ecs.TaskDefinition; readonly targetGroup: elb.ApplicationTargetGroup | undefined; readonly logGroup: logs.LogGroup; readonly serviceAlarms: ServiceAlarms | undefined; constructor(scope: constructs.Construct, id: string, props: FargateServiceProps); }