Skip to content

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,10 @@
"RuntimeVersion": "syn-nodejs-puppeteer-7.0",
"Schedule": {
"DurationInSeconds": "0",
"Expression": "rate(1 minute)"
"Expression": "rate(1 minute)",
"RetryConfig": {
"MaxRetries": 2
}
},
"StartCanaryAfterCreation": true,
"Tags": [
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const inlineAsset = new Canary(stack, 'InlineAsset', {
schedule: Schedule.rate(cdk.Duration.minutes(1)),
artifactsBucketLocation: { bucket, prefix },
runtime: Runtime.SYNTHETICS_NODEJS_PUPPETEER_7_0,
maxRetries: 2,
cleanup: Cleanup.LAMBDA,
});

Expand Down
13 changes: 13 additions & 0 deletions packages/aws-cdk-lib/aws-synthetics/lib/canary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ export interface CanaryProps {
*/
readonly schedule?: Schedule;

/**
* The amount of times the canary will automatically retry a failed run.
* This is only supported on the following runtimes or newer: `Runtime.SYNTHETICS_NODEJS_PUPPETEER_10_0`, `Runtime.SYNTHETICS_NODEJS_PLAYWRIGHT_2_0`, `Runtime.SYNTHETICS_PYTHON_SELENIUM_5_1`.
* Max retries can be set between 0 and 2. Canaries which time out after 10 minutes are automatically limited to one retry.
*
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_autoretry.html
* @default 0
*/
readonly maxRetries?: number;

/**
* Whether or not the canary should start after creation.
*
Expand Down Expand Up @@ -670,6 +680,9 @@ export class Canary extends cdk.Resource implements ec2.IConnectable {
return {
durationInSeconds: String(`${props.timeToLive?.toSeconds() ?? 0}`),
expression: props.schedule?.expressionString ?? 'rate(5 minutes)',
retryConfig: {
maxRetries: props.maxRetries ?? 0,
},
};
}

Expand Down
3 changes: 2 additions & 1 deletion packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ test('Basic canary properties work', () => {
failureRetentionPeriod: Duration.days(10),
startAfterCreation: false,
timeToLive: Duration.minutes(30),
maxRetries: 2,
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_8_0,
});

Expand All @@ -31,7 +32,7 @@ test('Basic canary properties work', () => {
SuccessRetentionPeriod: 10,
FailureRetentionPeriod: 10,
StartCanaryAfterCreation: false,
Schedule: Match.objectLike({ DurationInSeconds: '1800' }),
Schedule: Match.objectLike({ DurationInSeconds: '1800', RetryConfig: { MaxRetries: 2 } }),
RuntimeVersion: 'syn-nodejs-puppeteer-8.0',
});
});
Expand Down
Loading