Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(aws-ecs-patterns): adding support for custom HealthCheck while creating QueueProcessingFargateService #18219

Merged
merged 9 commits into from
Jan 25, 2022
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ec2 from '@aws-cdk/aws-ec2';
import { FargatePlatformVersion, FargateService, FargateTaskDefinition } from '@aws-cdk/aws-ecs';
import { FargatePlatformVersion, FargateService, FargateTaskDefinition, HealthCheck } from '@aws-cdk/aws-ecs';
import * as cxapi from '@aws-cdk/cx-api';
import { Construct } from 'constructs';
import { QueueProcessingServiceBase, QueueProcessingServiceBaseProps } from '../base/queue-processing-service-base';
Expand Down Expand Up @@ -69,6 +69,13 @@ export interface QueueProcessingFargateServiceProps extends QueueProcessingServi
*/
readonly containerName?: string;

/**
* The health check command and associated configuration parameters for the container.
*
* @default - Health check configuration from container.
*/
readonly healthCheck?: HealthCheck;

/**
* The subnets to associate with the service.
*
Expand Down Expand Up @@ -127,6 +134,7 @@ export class QueueProcessingFargateService extends QueueProcessingServiceBase {
environment: this.environment,
secrets: this.secrets,
logging: this.logDriver,
healthCheck: props.healthCheck,
});

// The desiredCount should be removed from the fargate service when the feature flag is removed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,15 @@
}
],
"Essential": true,
"HealthCheck": {
"Command": [
"CMD-SHELL",
"custom-healthcheck-command"
],
"Interval": 30,
"Retries": 3,
"Timeout": 5
},
"Image": {
"Fn::Join": [
"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ new QueueProcessingFargateService(stack, 'PublicQueueService', {
memoryLimitMiB: 512,
image: new ecs.AssetImage(path.join(__dirname, '..', 'sqs-reader')),
assignPublicIp: true,
healthCheck: {
command: ['custom-healthcheck-command'],
},
});

app.synth();