Skip to content

(aws-route53): cannot create HealthCheck with recovery control type #34262

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

Open
1 task
msysh opened this issue Apr 25, 2025 · 2 comments · May be fixed by #34272
Open
1 task

(aws-route53): cannot create HealthCheck with recovery control type #34262

msysh opened this issue Apr 25, 2025 · 2 comments · May be fixed by #34272
Labels
@aws-cdk/aws-route53 Related to Amazon Route 53 bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@msysh
Copy link
Contributor

msysh commented Apr 25, 2025

Describe the bug

Deployment of Route53 health check of type "Recovery Control" used in Application Recovery Controller fails with the following message:

"Invalid request provided: AWS::Route53::HealthCheck"

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

When the HealthCheck type is Recovery Control, it is expected that unnecessary properties should not be included in the HealthCheckConfig property of AWS::Route53::HealthCheck in the CloudFormation template generated from CDK code.

Current Behavior

When the HealthCheck type is Recovery Control, properties such as FailureThreshold, RequestInterval, and MeasureLatency are output to the CloudFormation template with default values, even though they are not explicitly specified in the CDK code.

Reproduction Steps

It can be reproduced with the following code:

import * as cdk from 'aws-cdk-lib';

const app = new cdk.App();
const stack = new cdk.Stack(app, 'Stack');

const cluster = new cdk.aws_route53recoverycontrol.CfnCluster(stack, 'Cluster', {
  name: 'cluster',
});

const controlPanel = new cdk.aws_route53recoverycontrol.CfnControlPanel(stack, 'ControlPanel', {
  name: 'control-panel',
  clusterArn: cluster.attrClusterArn,
});

const routingControl = new cdk.aws_route53recoverycontrol.CfnRoutingControl(stack, 'RoutingControl', {
  name: 'routing-control',
  clusterArn: cluster.attrClusterArn,
  controlPanelArn: controlPanel.attrControlPanelArn,
});

const healthCheck = new cdk.aws_route53.HealthCheck(stack, 'HealthCheck', {
  type: cdk.aws_route53.HealthCheckType.RECOVERY_CONTROL,
  routingControl: routingControl.attrRoutingControlArn,
});

Possible Solution

In health-check.ts, if HealthCheck type is Recovery Control, return undefined as default value for previous 3 properties (FailureThreshold, RequestInterval, and MeasureLatency).

The following codes will need to be modified to return undefined when health check type is RECOVERY_CONTROL:

function getDefaultFailureThresholdForType(type: HealthCheckType): number | undefined {
switch (type) {
case HealthCheckType.CALCULATED:
case HealthCheckType.CLOUDWATCH_METRIC:
return undefined;
default:
return 3;
}
}

function getDefaultRequestIntervalForType(type: HealthCheckType): Duration | undefined {
switch (type) {
case HealthCheckType.CALCULATED:
case HealthCheckType.CLOUDWATCH_METRIC:
return undefined;
default:
return Duration.seconds(30);
}
}

function getDefaultMeasureLatencyForType(type: HealthCheckType): boolean | undefined {
switch (type) {
case HealthCheckType.CALCULATED:
case HealthCheckType.CLOUDWATCH_METRIC:
return undefined;
default:
return false;
}
}

Additional Information/Context

Currently this problem can be avoided with an escape hatches as follows.

const cfnHealthCheck = healthCheck.node.defaultChild as cdk.aws_route53.CfnHealthCheck;
cfnHealthCheck.addPropertyDeletionOverride('HealthCheckConfig.FailureThreshold');
cfnHealthCheck.addPropertyDeletionOverride('HealthCheckConfig.RequestInterval');
cfnHealthCheck.addPropertyDeletionOverride('HealthCheckConfig.MeasureLatency');

CDK CLI Version

2.1012.0 (build e4c1f15) / aws-cdk-lib: 2.190.0

Framework Version

No response

Node.js Version

v22.14.0

OS

macOS 15.4

Language

TypeScript

Language Version

No response

Other information

No response

@msysh msysh added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 25, 2025
@github-actions github-actions bot added the @aws-cdk/aws-route53 Related to Amazon Route 53 label Apr 25, 2025
@msysh
Copy link
Contributor Author

msysh commented Apr 27, 2025

I corrected above because the Invert property doesn't need to be undefined. It seems okay to use false as the default value.

@pahud
Copy link
Contributor

pahud commented Apr 27, 2025

Hi @msysh,

Thanks for reporting this bug and providing detailed reproduction steps and analysis!

You've correctly identified that when creating a Route 53 HealthCheck with type: HealthCheckType.RECOVERY_CONTROL, the CDK construct is incorrectly adding default values for properties like FailureThreshold, Inverted, RequestInterval, and MeasureLatency to the synthesized CloudFormation template's HealthCheckConfig. These properties are indeed not applicable for the RECOVERY_CONTROL type and lead to deployment failures.

The root cause appears to be within the default value logic in the HealthCheck construct. The helper functions like getDefaultFailureThresholdForType, getDefaultMeasureLatencyForType, getDefaultRequestIntervalForType, and the direct default for inverted do not explicitly handle the RECOVERY_CONTROL case, causing them to fall back to inappropriate defaults.

Your proposed solution to modify these functions/logic to return undefined for the RECOVERY_CONTROL type seems like the correct approach.

We really appreciate you identifying this issue and suggesting a fix. Would you be interested in submitting a Pull Request to address this? We'd be happy to review it! In the meantime, your workaround using addPropertyDeletionOverride is a valid way to bypass the problem.

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Apr 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-route53 Related to Amazon Route 53 bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
2 participants