diff --git a/packages/@aws-cdk/aws-ecs-patterns/lib/fargate/network-load-balanced-fargate-service.ts b/packages/@aws-cdk/aws-ecs-patterns/lib/fargate/network-load-balanced-fargate-service.ts index e24af6774b42b..d2011a8f76133 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/lib/fargate/network-load-balanced-fargate-service.ts +++ b/packages/@aws-cdk/aws-ecs-patterns/lib/fargate/network-load-balanced-fargate-service.ts @@ -1,5 +1,5 @@ import { SubnetSelection } 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 { FeatureFlags } from '@aws-cdk/core'; import * as cxapi from '@aws-cdk/cx-api'; import { Construct } from 'constructs'; @@ -85,6 +85,15 @@ export interface NetworkLoadBalancedFargateServiceProps extends NetworkLoadBalan * @default Latest */ readonly platformVersion?: FargatePlatformVersion; + + /** + * The health check settings to use when evaluating the health of your EC2 instances. + * It is used for determining if a service is healthy and consists at least of an array of commands + * which are run when a health check is triggered. + * + * @default - Health check configuration from container. + */ + readonly healthCheck?: HealthCheck; } /** @@ -135,6 +144,7 @@ export class NetworkLoadBalancedFargateService extends NetworkLoadBalancedServic environment: taskImageOptions.environment, secrets: taskImageOptions.secrets, dockerLabels: taskImageOptions.dockerLabels, + healthCheck: props.healthCheck, }); container.addPortMappings({ containerPort: taskImageOptions.containerPort || 80, diff --git a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3.ts b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3.ts index b7cca5925e67c..775411687d85a 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3.ts +++ b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/integ.l3.ts @@ -28,6 +28,9 @@ new ecsPatterns.NetworkLoadBalancedFargateService(stack, 'NLBFargateService', { taskImageOptions: { image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'), }, + healthCheck: { + command: ['some command'], + }, }); app.synth(); diff --git a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/aws-ecs-integ-lb-fargate.assets.json b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/aws-ecs-integ-lb-fargate.assets.json index 3568f7d2db3bb..1ee0660746639 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/aws-ecs-integ-lb-fargate.assets.json +++ b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/aws-ecs-integ-lb-fargate.assets.json @@ -1,7 +1,7 @@ { - "version": "17.0.0", + "version": "20.0.0", "files": { - "df69d2ecce2a4821319e5d7c7a82c2788b52a69dd46e19809ca9d208bf17231f": { + "5ad71626a2e88b8d545b41d9d9ac40a67383269e200e803c6f0568ea8d694f53": { "source": { "path": "aws-ecs-integ-lb-fargate.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "df69d2ecce2a4821319e5d7c7a82c2788b52a69dd46e19809ca9d208bf17231f.json", + "objectKey": "5ad71626a2e88b8d545b41d9d9ac40a67383269e200e803c6f0568ea8d694f53.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/aws-ecs-integ-lb-fargate.template.json b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/aws-ecs-integ-lb-fargate.template.json index 5d9f94b76397a..df262db9628a2 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/aws-ecs-integ-lb-fargate.template.json +++ b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/aws-ecs-integ-lb-fargate.template.json @@ -776,6 +776,15 @@ "ContainerDefinitions": [ { "Essential": true, + "HealthCheck": { + "Command": [ + "CMD-SHELL", + "some command" + ], + "Interval": 30, + "Retries": 3, + "Timeout": 5 + }, "Image": "amazon/amazon-ecs-sample", "LogConfiguration": { "LogDriver": "awslogs", diff --git a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/cdk.out b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/cdk.out index 90bef2e09ad39..588d7b269d34f 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/cdk.out @@ -1 +1 @@ -{"version":"17.0.0"} \ No newline at end of file +{"version":"20.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/integ.json b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/integ.json index 70cdb7117a70a..d177c41b4169b 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/integ.json +++ b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/integ.json @@ -1,7 +1,7 @@ { - "version": "18.0.0", + "version": "20.0.0", "testCases": { - "aws-ecs-patterns/test/fargate/integ.l3": { + "fargate/integ.l3": { "stacks": [ "aws-ecs-integ-lb-fargate" ], diff --git a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/manifest.json b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/manifest.json index c602c776fa209..4166afe50c2b7 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "17.0.0", + "version": "20.0.0", "artifacts": { "Tree": { "type": "cdk:tree", @@ -282,7 +282,10 @@ "/aws-ecs-integ-lb-fargate/NLBFargateService/TaskDef/Resource": [ { "type": "aws:cdk:logicalId", - "data": "NLBFargateServiceTaskDefB836FA89" + "data": "NLBFargateServiceTaskDefB836FA89", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_REPLACE" + ] } ], "/aws-ecs-integ-lb-fargate/NLBFargateService/TaskDef/web/LogGroup/Resource": [ diff --git a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/tree.json b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/tree.json index cdad7d71d1930..4933ae1b8ed7c 100644 --- a/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/tree.json +++ b/packages/@aws-cdk/aws-ecs-patterns/test/fargate/l3.integ.snapshot/tree.json @@ -9,7 +9,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.0.9" + "version": "10.1.33" } }, "aws-ecs-integ-lb-fargate": { @@ -1418,6 +1418,15 @@ "Ref": "AWS::Region" } } + }, + "healthCheck": { + "command": [ + "CMD-SHELL", + "some command" + ], + "interval": 30, + "retries": 3, + "timeout": 5 } } ],