-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
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
:
aws-cdk/packages/aws-cdk-lib/aws-route53/lib/health-check.ts
Lines 331 to 339 in 7f378b6
function getDefaultFailureThresholdForType(type: HealthCheckType): number | undefined { | |
switch (type) { | |
case HealthCheckType.CALCULATED: | |
case HealthCheckType.CLOUDWATCH_METRIC: | |
return undefined; | |
default: | |
return 3; | |
} | |
} |
aws-cdk/packages/aws-cdk-lib/aws-route53/lib/health-check.ts
Lines 341 to 349 in 7f378b6
function getDefaultRequestIntervalForType(type: HealthCheckType): Duration | undefined { | |
switch (type) { | |
case HealthCheckType.CALCULATED: | |
case HealthCheckType.CLOUDWATCH_METRIC: | |
return undefined; | |
default: | |
return Duration.seconds(30); | |
} | |
} |
aws-cdk/packages/aws-cdk-lib/aws-route53/lib/health-check.ts
Lines 313 to 321 in 7f378b6
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