Skip to content

delete_function

delete_function(
    name: FunctionName,
    if_match: string,
    *,
    config_overrides: Optional[CloudFrontClientConfig] = None,
) -> None

Deletes a CloudFront function.

You cannot delete a function if it's associated with a cache behavior. First, update your distributions to remove the function association from all cache behaviors, then delete the function.

To delete a function, you must provide the function's name and version (ETag value). To get these values, you can use ListFunctions and DescribeFunction.

Parameters:

  • name (FunctionName) –

    The name of the function that you are deleting.

  • if_match (string) –

    The current version (ETag value) of the function that you are deleting, which you can get using DescribeFunction.

Raises:

Source code in docs_src/capo_cloudfront/_services/cloud_front.py
def delete_function(
    self,
    name: "capo_cloudfront.types.function_name.FunctionName",
    if_match: "capo_cloudfront.types.string.string",
    *,
    config_overrides: Optional[CloudFrontClientConfig] = None,
) -> None:
    """<p>Deletes a CloudFront function.</p> <p>You cannot delete a function if it's associated with a cache behavior. First, update your distributions to remove the function association from all cache behaviors, then delete the function.</p> <p>To delete a function, you must provide the function's name and version (<code>ETag</code> value). To get these values, you can use <code>ListFunctions</code> and <code>DescribeFunction</code>.</p>

    Args:
        name: <p>The name of the function that you are deleting.</p>
        if_match: <p>The current version (<code>ETag</code> value) of the function that you are deleting, which you can get using <code>DescribeFunction</code>.</p>

    Raises:
        capo_cloudfront.errors.function_in_use.FunctionInUse: <p>Cannot delete the function because it's attached to one or more cache behaviors.</p>
        capo_cloudfront.errors.invalid_if_match_version.InvalidIfMatchVersion: <p>The <code>If-Match</code> version is missing or not valid.</p>
        capo_cloudfront.errors.no_such_function_exists.NoSuchFunctionExists: <p>The function does not exist.</p>
        capo_cloudfront.errors.precondition_failed.PreconditionFailed: <p>The precondition in one or more of the request fields evaluated to <code>false</code>.</p>
        capo_cloudfront.errors.unsupported_operation.UnsupportedOperation: <p>This operation is not supported in this Amazon Web Services Region.</p>
        capo_cloudfront.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_cloudfront.types.delete_function_request.DeleteFunctionRequest]",
    ) -> OperationResponse[None]:
        import capo_cloudfront._operations.cloudfront2020_05_31.delete_function

        output, http_response = (
            capo_cloudfront._operations.cloudfront2020_05_31.delete_function.delete_function(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteFunction")
    )
    input_: capo_cloudfront.types.delete_function_request.DeleteFunctionRequest = {
        "name": name,
        "if_match": if_match,
    }

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