Skip to content

(aws-synthetics): Add support for configuring automatic retries of Canary runs #34511

Open
@georeeve

Description

@georeeve

Describe the feature

You can now configure AWS Synthetics Canaries to retry failed runs (https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_autoretry.html). There is support in CFN to do this via an optional RetryConfig structure within the Schedule structure (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-synthetics-canary-schedule.html):

{
  "MaxRetries" : Integer
}

Use Case

To match the CFN resource.

Proposed Solution

I think we're still waiting on the automated PR to update the L1 CloudFormation resource definitions for this, but I thought we could handle it similarly to how we're already handling the durationInSeconds part of the Schedule structure. For example by creating a maxRetries prop and updating the createSchedule function:

/**
 * Returns a canary schedule object
 */
private createSchedule(props: CanaryProps): CfnCanary.ScheduleProperty {
  return {
    durationInSeconds: String(`${props.timeToLive?.toSeconds() ?? 0}`),
    expression: props.schedule?.expressionString ?? 'rate(5 minutes)',
    retryConfig: props.maxRetries ? {
      maxRetries: props.maxRetries,
    } : undefined,
  };
}

I'm happy to try and implement this and create a PR for it.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS CDK Library version (aws-cdk-lib)

2.197.0

AWS CDK CLI version

2.1016.1

Environment details (OS name and version, etc.)

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions