updateCanary method

Future<void> updateCanary({
  1. required String name,
  2. ArtifactConfigInput? artifactConfig,
  3. String? artifactS3Location,
  4. List<BrowserConfig>? browserConfigs,
  5. CanaryCodeInput? code,
  6. String? dryRunId,
  7. String? executionRoleArn,
  8. int? failureRetentionPeriodInDays,
  9. ProvisionedResourceCleanupSetting? provisionedResourceCleanup,
  10. CanaryRunConfigInput? runConfig,
  11. String? runtimeVersion,
  12. CanaryScheduleInput? schedule,
  13. int? successRetentionPeriodInDays,
  14. VisualReferenceInput? visualReference,
  15. List<VisualReferenceInput>? visualReferences,
  16. VpcConfigInput? vpcConfig,
})

Updates the configuration of a canary that has already been created.

For multibrowser canaries, you can add or remove browsers by updating the browserConfig list in the update call. For example:

  • To add Firefox to a canary that currently uses Chrome, specify browserConfigs as \[CHROME, FIREFOX\]
  • To remove Firefox and keep only Chrome, specify browserConfigs as \[CHROME\]
You can't use this operation to update the tags of an existing canary. To change the tags of an existing canary, use TagResource.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw RequestEntityTooLargeException. May throw ResourceNotFoundException. May throw ValidationException.

Parameter name : The name of the canary that you want to update. To find the names of your canaries, use DescribeCanaries.

You cannot change the name of a canary that has already been created.

Parameter artifactConfig : A structure that contains the configuration for canary artifacts, including the encryption-at-rest settings for artifacts that the canary uploads to Amazon S3.

Parameter artifactS3Location : The location in Amazon S3 where Synthetics stores artifacts from the test runs of this canary. Artifacts include the log file, screenshots, and HAR files. The name of the Amazon S3 bucket can't include a period (.).

Parameter browserConfigs : A structure that specifies the browser type to use for a canary run. CloudWatch Synthetics supports running canaries on both CHROME and FIREFOX browsers.

Parameter code : A structure that includes the entry point from which the canary should start running your script. If the script is stored in an Amazon S3 bucket, the bucket name, key, and version are also included.

Parameter dryRunId : Update the existing canary using the updated configurations from the DryRun associated with the DryRunId.

Parameter executionRoleArn : The ARN of the IAM role to be used to run the canary. This role must already exist, and must include lambda.amazonaws.com as a principal in the trust policy. The role must also have the following permissions:

  • s3:PutObject
  • s3:GetBucketLocation
  • s3:ListAllMyBuckets
  • cloudwatch:PutMetricData
  • logs:CreateLogGroup
  • logs:CreateLogStream
  • logs:CreateLogStream

Parameter failureRetentionPeriodInDays : The number of days to retain data about failed runs of this canary.

This setting affects the range of information returned by GetCanaryRuns, as well as the range of information displayed in the Synthetics console.

Parameter provisionedResourceCleanup : Specifies whether to also delete the Lambda functions and layers used by this canary when the canary is deleted.

If the value of this parameter is OFF, then the value of the DeleteLambda parameter of the DeleteCanary operation determines whether the Lambda functions and layers will be deleted.

Parameter runConfig : A structure that contains the timeout value that is used for each individual run of the canary.

Parameter runtimeVersion : Specifies the runtime version to use for the canary. For a list of valid runtime versions and for more information about runtime versions, see Canary Runtime Versions.

Parameter schedule : A structure that contains information about how often the canary is to run, and when these runs are to stop.

Parameter successRetentionPeriodInDays : The number of days to retain data about successful runs of this canary.

This setting affects the range of information returned by GetCanaryRuns, as well as the range of information displayed in the Synthetics console.

Parameter visualReference : Defines the screenshots to use as the baseline for comparisons during visual monitoring comparisons during future runs of this canary. If you omit this parameter, no changes are made to any baseline screenshots that the canary might be using already.

Visual monitoring is supported only on canaries running the syn-puppeteer-node-3.2 runtime or later. For more information, see Visual monitoring and Visual monitoring blueprint

Parameter visualReferences : A list of visual reference configurations for the canary, one for each browser type that the canary is configured to run on. Visual references are used for visual monitoring comparisons.

syn-nodejs-puppeteer-11.0 and above, and syn-nodejs-playwright-3.0 and above, only supports visualReferences. visualReference field is not supported.

Versions older than syn-nodejs-puppeteer-11.0 supports both visualReference and visualReferences for backward compatibility. It is recommended to use visualReferences for consistency and future compatibility.

For multibrowser visual monitoring, you can update the baseline for all configured browsers in a single update call by specifying a list of VisualReference objects, one per browser. Each VisualReference object maps to a specific browser configuration, allowing you to manage visual baselines for multiple browsers simultaneously.

For single configuration canaries using Chrome browser (default browser), use visualReferences for syn-nodejs-puppeteer-11.0 and above, and syn-nodejs-playwright-3.0 and above canaries. The browserType in the visualReference object is not mandatory.

Parameter vpcConfig : If this canary is to test an endpoint in a VPC, this structure contains information about the subnet and security groups of the VPC endpoint. For more information, see Running a Canary in a VPC.

Implementation

Future<void> updateCanary({
  required String name,
  ArtifactConfigInput? artifactConfig,
  String? artifactS3Location,
  List<BrowserConfig>? browserConfigs,
  CanaryCodeInput? code,
  String? dryRunId,
  String? executionRoleArn,
  int? failureRetentionPeriodInDays,
  ProvisionedResourceCleanupSetting? provisionedResourceCleanup,
  CanaryRunConfigInput? runConfig,
  String? runtimeVersion,
  CanaryScheduleInput? schedule,
  int? successRetentionPeriodInDays,
  VisualReferenceInput? visualReference,
  List<VisualReferenceInput>? visualReferences,
  VpcConfigInput? vpcConfig,
}) async {
  _s.validateNumRange(
    'failureRetentionPeriodInDays',
    failureRetentionPeriodInDays,
    1,
    1024,
  );
  _s.validateNumRange(
    'successRetentionPeriodInDays',
    successRetentionPeriodInDays,
    1,
    1024,
  );
  final $payload = <String, dynamic>{
    if (artifactConfig != null) 'ArtifactConfig': artifactConfig,
    if (artifactS3Location != null) 'ArtifactS3Location': artifactS3Location,
    if (browserConfigs != null) 'BrowserConfigs': browserConfigs,
    if (code != null) 'Code': code,
    if (dryRunId != null) 'DryRunId': dryRunId,
    if (executionRoleArn != null) 'ExecutionRoleArn': executionRoleArn,
    if (failureRetentionPeriodInDays != null)
      'FailureRetentionPeriodInDays': failureRetentionPeriodInDays,
    if (provisionedResourceCleanup != null)
      'ProvisionedResourceCleanup': provisionedResourceCleanup.value,
    if (runConfig != null) 'RunConfig': runConfig,
    if (runtimeVersion != null) 'RuntimeVersion': runtimeVersion,
    if (schedule != null) 'Schedule': schedule,
    if (successRetentionPeriodInDays != null)
      'SuccessRetentionPeriodInDays': successRetentionPeriodInDays,
    if (visualReference != null) 'VisualReference': visualReference,
    if (visualReferences != null) 'VisualReferences': visualReferences,
    if (vpcConfig != null) 'VpcConfig': vpcConfig,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PATCH',
    requestUri: '/canary/${Uri.encodeComponent(name)}',
    exceptionFnMap: _exceptionFns,
  );
}