Skip to content

update_canary

update_canary(
    name: CanaryName,
    *,
    config_overrides: Optional[syntheticsClientConfig] = None,
    code: Optional[CanaryCodeInput] = None,
    execution_role_arn: Optional[RoleArn] = None,
    runtime_version: Optional[String] = None,
    schedule: Optional[CanaryScheduleInput] = None,
    run_config: Optional[CanaryRunConfigInput] = None,
    success_retention_period_in_days: Optional[MaxSize1024] = None,
    failure_retention_period_in_days: Optional[MaxSize1024] = None,
    vpc_config: Optional[VpcConfigInput] = None,
    visual_reference: Optional[VisualReferenceInput] = None,
    artifact_s3_location: Optional[String] = None,
    artifact_config: Optional[ArtifactConfigInput] = None,
    provisioned_resource_cleanup: Optional[ProvisionedResourceCleanupSetting] = None,
    dry_run_id: Optional[UUID] = None,
    visual_references: Optional[VisualReferences] = None,
    browser_configs: Optional[BrowserConfigs] = None,
    add_replica_locations: Optional[AddReplicaLocations] = None,
    remove_replica_locations: Optional[RemoveReplicaLocations] = None,
    kms_key_arn: Optional[KmsKeyArn] = None,
) -> UpdateCanaryResponse

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.

When you use the dryRunId field when updating a canary, the only other field you can provide is the Schedule. Adding any other field will thrown an exception.

Parameters:

  • name (CanaryName) –

    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.

  • code (Optional[CanaryCodeInput], default: None ) –

    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.

  • execution_role_arn (Optional[RoleArn], default: None ) –

    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

  • runtime_version (Optional[String], default: None ) –

    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.

  • schedule (Optional[CanaryScheduleInput], default: None ) –

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

  • run_config (Optional[CanaryRunConfigInput], default: None ) –

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

    Environment variable keys and values are encrypted at rest using Amazon Web Services owned KMS keys. However, the environment variables are not encrypted on the client side. Do not store sensitive information in them.

  • success_retention_period_in_days (Optional[MaxSize1024], default: None ) –

    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.

  • failure_retention_period_in_days (Optional[MaxSize1024], default: None ) –

    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.

  • vpc_config (Optional[VpcConfigInput], default: None ) –

    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.

  • visual_reference (Optional[VisualReferenceInput], default: None ) –

    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

  • artifact_s3_location (Optional[String], default: None ) –

    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 (.).

  • artifact_config (Optional[ArtifactConfigInput], default: None ) –

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

  • provisioned_resource_cleanup (Optional[ProvisionedResourceCleanupSetting], default: None ) –

    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.

  • dry_run_id (Optional[UUID], default: None ) –

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

    When you use the dryRunId field when updating a canary, the only other field you can provide is the Schedule. Adding any other field will thrown an exception.

  • visual_references (Optional[VisualReferences], default: None ) –

    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.

  • browser_configs (Optional[BrowserConfigs], default: None ) –

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

    If not specified, browserConfigs defaults to Chrome.

  • add_replica_locations (Optional[AddReplicaLocations], default: None ) –

    A list of locations (Amazon Web Services Regions) to add as replicas for the canary. Each location specifies a Region and optional VPC configuration for the replica. You can add up to 50 replica locations.

  • remove_replica_locations (Optional[RemoveReplicaLocations], default: None ) –

    A list of locations (Amazon Web Services Regions) to remove as replicas for the canary. You must specify at least one location to remove. All replicas can be removed in a single API call and you cannot remove the primary location.

  • kms_key_arn (Optional[KmsKeyArn], default: None ) –

    The Amazon Resource Name (ARN) of the customer-managed AWS Key Management Service (AWS KMS) key used to encrypt the canary's AWS Lambda function environment variables at rest. If you don't specify a value, the service uses an AWS-managed key. If you omit this parameter, the service retains the existing value. To revert to the AWS-managed key, set this parameter to an empty string.

Raises:

Source code in docs_src/capo_synthetics/_services/synthetics.py
def update_canary(
    self,
    name: "capo_synthetics.types.canary_name.CanaryName",
    *,
    config_overrides: Optional[syntheticsClientConfig] = None,
    code: Optional[
        "capo_synthetics.types.canary_code_input.CanaryCodeInput"
    ] = None,
    execution_role_arn: Optional["capo_synthetics.types.role_arn.RoleArn"] = None,
    runtime_version: Optional["capo_synthetics.types.string.String"] = None,
    schedule: Optional[
        "capo_synthetics.types.canary_schedule_input.CanaryScheduleInput"
    ] = None,
    run_config: Optional[
        "capo_synthetics.types.canary_run_config_input.CanaryRunConfigInput"
    ] = None,
    success_retention_period_in_days: Optional[
        "capo_synthetics.types.max_size1024.MaxSize1024"
    ] = None,
    failure_retention_period_in_days: Optional[
        "capo_synthetics.types.max_size1024.MaxSize1024"
    ] = None,
    vpc_config: Optional[
        "capo_synthetics.types.vpc_config_input.VpcConfigInput"
    ] = None,
    visual_reference: Optional[
        "capo_synthetics.types.visual_reference_input.VisualReferenceInput"
    ] = None,
    artifact_s3_location: Optional["capo_synthetics.types.string.String"] = None,
    artifact_config: Optional[
        "capo_synthetics.types.artifact_config_input.ArtifactConfigInput"
    ] = None,
    provisioned_resource_cleanup: Optional[
        "capo_synthetics.types.provisioned_resource_cleanup_setting.ProvisionedResourceCleanupSetting"
    ] = None,
    dry_run_id: Optional["capo_synthetics.types.uuid.UUID"] = None,
    visual_references: Optional[
        "capo_synthetics.types.visual_references.VisualReferences"
    ] = None,
    browser_configs: Optional[
        "capo_synthetics.types.browser_configs.BrowserConfigs"
    ] = None,
    add_replica_locations: Optional[
        "capo_synthetics.types.add_replica_locations.AddReplicaLocations"
    ] = None,
    remove_replica_locations: Optional[
        "capo_synthetics.types.remove_replica_locations.RemoveReplicaLocations"
    ] = None,
    kms_key_arn: Optional["capo_synthetics.types.kms_key_arn.KmsKeyArn"] = None,
) -> "capo_synthetics.types.update_canary_response.UpdateCanaryResponse":
    """<p>Updates the configuration of a canary that has already been created.</p> <p>For multibrowser canaries, you can add or remove browsers by updating the browserConfig list in the update call. For example:</p> <ul> <li> <p>To add Firefox to a canary that currently uses Chrome, specify browserConfigs as [CHROME, FIREFOX]</p> </li> <li> <p>To remove Firefox and keep only Chrome, specify browserConfigs as [CHROME]</p> </li> </ul> <p>You can't use this operation to update the tags of an existing canary. To change the tags of an existing canary, use <a href="https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_TagResource.html">TagResource</a>.</p> <note> <p>When you use the <code>dryRunId</code> field when updating a canary, the only other field you can provide is the <code>Schedule</code>. Adding any other field will thrown an exception.</p> </note>

    Args:
        name: <p>The name of the canary that you want to update. To find the names of your canaries, use <a href="https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_DescribeCanaries.html">DescribeCanaries</a>.</p> <p>You cannot change the name of a canary that has already been created.</p>
        code: <p>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. </p>
        execution_role_arn: <p>The ARN of the IAM role to be used to run the canary. This role must already exist, and must include <code>lambda.amazonaws.com</code> as a principal in the trust policy. The role must also have the following permissions:</p> <ul> <li> <p> <code>s3:PutObject</code> </p> </li> <li> <p> <code>s3:GetBucketLocation</code> </p> </li> <li> <p> <code>s3:ListAllMyBuckets</code> </p> </li> <li> <p> <code>cloudwatch:PutMetricData</code> </p> </li> <li> <p> <code>logs:CreateLogGroup</code> </p> </li> <li> <p> <code>logs:CreateLogStream</code> </p> </li> <li> <p> <code>logs:CreateLogStream</code> </p> </li> </ul>
        runtime_version: <p>Specifies the runtime version to use for the canary. For a list of valid runtime versions and for more information about runtime versions, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_Library.html"> Canary Runtime Versions</a>.</p>
        schedule: <p>A structure that contains information about how often the canary is to run, and when these runs are to stop.</p>
        run_config: <p>A structure that contains the timeout value that is used for each individual run of the canary.</p> <important> <p>Environment variable keys and values are encrypted at rest using Amazon Web Services owned KMS keys. However, the environment variables are not encrypted on the client side. Do not store sensitive information in them.</p> </important>
        success_retention_period_in_days: <p>The number of days to retain data about successful runs of this canary.</p> <p>This setting affects the range of information returned by <a href="https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_GetCanaryRuns.html">GetCanaryRuns</a>, as well as the range of information displayed in the Synthetics console. </p>
        failure_retention_period_in_days: <p>The number of days to retain data about failed runs of this canary.</p> <p>This setting affects the range of information returned by <a href="https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_GetCanaryRuns.html">GetCanaryRuns</a>, as well as the range of information displayed in the Synthetics console. </p>
        vpc_config: <p>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 <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_VPC.html"> Running a Canary in a VPC</a>.</p>
        visual_reference: <p>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.</p> <p>Visual monitoring is supported only on canaries running the <b>syn-puppeteer-node-3.2</b> runtime or later. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_SyntheticsLogger_VisualTesting.html"> Visual monitoring</a> and <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_Blueprints_VisualTesting.html"> Visual monitoring blueprint</a> </p>
        artifact_s3_location: <p>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 (.).</p>
        artifact_config: <p>A structure that contains the configuration for canary artifacts, including the encryption-at-rest settings for artifacts that the canary uploads to Amazon S3.</p>
        provisioned_resource_cleanup: <p>Specifies whether to also delete the Lambda functions and layers used by this canary when the canary is deleted.</p> <p>If the value of this parameter is <code>OFF</code>, then the value of the <code>DeleteLambda</code> parameter of the <a href="https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_DeleteCanary.html">DeleteCanary</a> operation determines whether the Lambda functions and layers will be deleted.</p>
        dry_run_id: <p>Update the existing canary using the updated configurations from the DryRun associated with the DryRunId.</p> <note> <p>When you use the <code>dryRunId</code> field when updating a canary, the only other field you can provide is the <code>Schedule</code>. Adding any other field will thrown an exception.</p> </note>
        visual_references: <p>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.</p> <p> <code>syn-nodejs-puppeteer-11.0</code> and above, and <code>syn-nodejs-playwright-3.0</code> and above, only supports <code>visualReferences</code>. <code>visualReference</code> field is not supported.</p> <p>Versions older than <code>syn-nodejs-puppeteer-11.0</code> supports both <code>visualReference</code> and <code>visualReferences</code> for backward compatibility. It is recommended to use <code>visualReferences</code> for consistency and future compatibility.</p> <p>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.</p> <p>For single configuration canaries using Chrome browser (default browser), use visualReferences for <code>syn-nodejs-puppeteer-11.0</code> and above, and <code>syn-nodejs-playwright-3.0</code> and above canaries. The browserType in the visualReference object is not mandatory.</p>
        browser_configs: <p>A structure that specifies the browser type to use for a canary run. CloudWatch Synthetics supports running canaries on both <code>CHROME</code> and <code>FIREFOX</code> browsers.</p> <note> <p>If not specified, <code>browserConfigs</code> defaults to Chrome.</p> </note>
        add_replica_locations: <p>A list of locations (Amazon Web Services Regions) to add as replicas for the canary. Each location specifies a Region and optional VPC configuration for the replica. You can add up to 50 replica locations.</p>
        remove_replica_locations: <p>A list of locations (Amazon Web Services Regions) to remove as replicas for the canary. You must specify at least one location to remove. All replicas can be removed in a single API call and you cannot remove the primary location.</p>
        kms_key_arn: <p>The Amazon Resource Name (ARN) of the customer-managed AWS Key Management Service (AWS KMS) key used to encrypt the canary's AWS Lambda function environment variables at rest. If you don't specify a value, the service uses an AWS-managed key. If you omit this parameter, the service retains the existing value. To revert to the AWS-managed key, set this parameter to an empty string.</p>

    Raises:
        capo_synthetics.errors.access_denied_exception.AccessDeniedException: <p>You don't have permission to perform this operation on this resource.</p>
        capo_synthetics.errors.conflict_exception.ConflictException: <p>A conflicting operation is already in progress.</p>
        capo_synthetics.errors.internal_server_exception.InternalServerException: <p>An unknown internal error occurred.</p>
        capo_synthetics.errors.request_entity_too_large_exception.RequestEntityTooLargeException: <p>One of the input resources is larger than is allowed.</p>
        capo_synthetics.errors.resource_not_found_exception.ResourceNotFoundException: <p>One of the specified resources was not found.</p>
        capo_synthetics.errors.validation_exception.ValidationException: <p>A parameter could not be validated.</p>
        capo_synthetics.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_synthetics.types.update_canary_request.UpdateCanaryRequest]",
    ) -> OperationResponse[
        "capo_synthetics.types.update_canary_response.UpdateCanaryResponse"
    ]:
        import capo_synthetics._operations.synthetics.update_canary

        output, http_response = (
            capo_synthetics._operations.synthetics.update_canary.update_canary(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateCanary")
    )
    input_: capo_synthetics.types.update_canary_request.UpdateCanaryRequest = {
        "name": name
    }
    if code is not None:
        input_["code"] = code
    if execution_role_arn is not None:
        input_["execution_role_arn"] = execution_role_arn
    if runtime_version is not None:
        input_["runtime_version"] = runtime_version
    if schedule is not None:
        input_["schedule"] = schedule
    if run_config is not None:
        input_["run_config"] = run_config
    if success_retention_period_in_days is not None:
        input_["success_retention_period_in_days"] = (
            success_retention_period_in_days
        )
    if failure_retention_period_in_days is not None:
        input_["failure_retention_period_in_days"] = (
            failure_retention_period_in_days
        )
    if vpc_config is not None:
        input_["vpc_config"] = vpc_config
    if visual_reference is not None:
        input_["visual_reference"] = visual_reference
    if artifact_s3_location is not None:
        input_["artifact_s3_location"] = artifact_s3_location
    if artifact_config is not None:
        input_["artifact_config"] = artifact_config
    if provisioned_resource_cleanup is not None:
        input_["provisioned_resource_cleanup"] = provisioned_resource_cleanup
    if dry_run_id is not None:
        input_["dry_run_id"] = dry_run_id
    if visual_references is not None:
        input_["visual_references"] = visual_references
    if browser_configs is not None:
        input_["browser_configs"] = browser_configs
    if add_replica_locations is not None:
        input_["add_replica_locations"] = add_replica_locations
    if remove_replica_locations is not None:
        input_["remove_replica_locations"] = remove_replica_locations
    if kms_key_arn is not None:
        input_["kms_key_arn"] = kms_key_arn

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output