Skip to content

delete_canary

delete_canary(
    name: CanaryName,
    *,
    config_overrides: Optional[syntheticsClientConfig] = None,
    delete_lambda: Optional[boolean] = None,
) -> DeleteCanaryResponse

Permanently deletes the specified canary.

If the canary's ProvisionedResourceCleanup field is set to AUTOMATIC or you specify DeleteLambda in this operation as true, CloudWatch Synthetics also deletes the Lambda functions and layers that are used by the canary.

Other resources used and created by the canary are not automatically deleted. After you delete a canary, you should also delete the following:

  • The CloudWatch alarms created for this canary. These alarms have a name of Synthetics-Alarm-first-198-characters-of-canary-name-canaryId-alarm number

  • Amazon S3 objects and buckets, such as the canary's artifact location.

  • IAM roles created for the canary. If they were created in the console, these roles have the name role/service-role/CloudWatchSyntheticsRole-First-21-Characters-of-CanaryName

  • CloudWatch Logs log groups created for the canary. These logs groups have the name /aws/lambda/cwsyn-First-21-Characters-of-CanaryName

Before you delete a canary, you might want to use GetCanary to display the information about this canary. Make note of the information returned by this operation so that you can delete these resources after you delete the canary.

Parameters:

  • name (CanaryName) –

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

  • delete_lambda (Optional[boolean], default: None ) –

    Specifies whether to also delete the Lambda functions and layers used by this canary. The default is false.

    Your setting for this parameter is used only if the canary doesn't have AUTOMATIC for its ProvisionedResourceCleanup field. If that field is set to AUTOMATIC, then the Lambda functions and layers will be deleted when this canary is deleted.

    Type: Boolean

Raises:

Source code in docs_src/capo_synthetics/_services/synthetics.py
def delete_canary(
    self,
    name: "capo_synthetics.types.canary_name.CanaryName",
    *,
    config_overrides: Optional[syntheticsClientConfig] = None,
    delete_lambda: Optional["capo_synthetics.types.boolean.boolean"] = None,
) -> "capo_synthetics.types.delete_canary_response.DeleteCanaryResponse":
    """<p>Permanently deletes the specified canary.</p> <p>If the canary's <code>ProvisionedResourceCleanup</code> field is set to <code>AUTOMATIC</code> or you specify <code>DeleteLambda</code> in this operation as <code>true</code>, CloudWatch Synthetics also deletes the Lambda functions and layers that are used by the canary.</p> <p>Other resources used and created by the canary are not automatically deleted. After you delete a canary, you should also delete the following:</p> <ul> <li> <p>The CloudWatch alarms created for this canary. These alarms have a name of <code>Synthetics-Alarm-<i>first-198-characters-of-canary-name</i>-<i>canaryId</i>-<i>alarm number</i> </code> </p> </li> <li> <p>Amazon S3 objects and buckets, such as the canary's artifact location.</p> </li> <li> <p>IAM roles created for the canary. If they were created in the console, these roles have the name <code> role/service-role/CloudWatchSyntheticsRole-<i>First-21-Characters-of-CanaryName</i> </code> </p> </li> <li> <p>CloudWatch Logs log groups created for the canary. These logs groups have the name <code>/aws/lambda/cwsyn-<i>First-21-Characters-of-CanaryName</i> </code> </p> </li> </ul> <p>Before you delete a canary, you might want to use <code>GetCanary</code> to display the information about this canary. Make note of the information returned by this operation so that you can delete these resources after you delete the canary.</p>

    Args:
        name: <p>The name of the canary that you want to delete. To find the names of your canaries, use <a href="https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_DescribeCanaries.html">DescribeCanaries</a>.</p>
        delete_lambda: <p>Specifies whether to also delete the Lambda functions and layers used by this canary. The default is <code>false</code>.</p> <p>Your setting for this parameter is used only if the canary doesn't have <code>AUTOMATIC</code> for its <code>ProvisionedResourceCleanup</code> field. If that field is set to <code>AUTOMATIC</code>, then the Lambda functions and layers will be deleted when this canary is deleted. </p> <p>Type: Boolean</p>

    Raises:
        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.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.delete_canary_request.DeleteCanaryRequest]",
    ) -> OperationResponse[
        "capo_synthetics.types.delete_canary_response.DeleteCanaryResponse"
    ]:
        import capo_synthetics._operations.synthetics.delete_canary

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteCanary")
    )
    input_: capo_synthetics.types.delete_canary_request.DeleteCanaryRequest = {
        "name": name
    }
    if delete_lambda is not None:
        input_["delete_lambda"] = delete_lambda

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