Skip to content

delete_function

delete_function(
    function_name: NamespacedFunctionName,
    *,
    config_overrides: Optional[LambdaClientConfig] = None,
    qualifier: Optional[NumericLatestPublishedOrAliasQualifier] = None,
) -> DeleteFunctionResponse

Deletes a Lambda Event Function. To delete a specific function version, use the Qualifier parameter. Otherwise, all versions and aliases are deleted. This doesn't require the user to have explicit permissions for DeleteAlias.

A deleted Lambda function cannot be recovered. Ensure that you specify the correct function name and version before deleting.

To delete Lambda event source mappings that invoke a function, use DeleteEventSourceMapping. For Amazon Web Services services and resources that invoke your function directly, delete the trigger in the service where you originally configured it.

Parameters:

  • function_name (NamespacedFunctionName) –

    The name or ARN of the Lambda function or version.

    Name formats

    • Function name – my-function (name-only), my-function:1 (with version).

    • Function ARN – arn:aws:lambda:us-west-2:123456789012:function:my-function.

    • Partial ARN – 123456789012:function:my-function.

    You can append a version number or alias to any of the formats. The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length.

  • qualifier (Optional[NumericLatestPublishedOrAliasQualifier], default: None ) –

    Specify a version to delete. You can't delete a version that an alias references.

Raises:

Examples:

To delete a version of a Lambda function The following example deletes version 1 of a Lambda function named my-function.

>>> client.delete_function(function_name='my-function', qualifier='1')
Source code in docs_src/capo_lambda/_services/_lambda.py
def delete_function(
    self,
    function_name: "capo_lambda.types.namespaced_function_name.NamespacedFunctionName",
    *,
    config_overrides: Optional[LambdaClientConfig] = None,
    qualifier: Optional[
        "capo_lambda.types.numeric_latest_published_or_alias_qualifier.NumericLatestPublishedOrAliasQualifier"
    ] = None,
) -> "capo_lambda.types.delete_function_response.DeleteFunctionResponse":
    """<p>Deletes a Lambda Event Function. To delete a specific function version, use the <code>Qualifier</code> parameter. Otherwise, all versions and aliases are deleted. This doesn't require the user to have explicit permissions for <a>DeleteAlias</a>.</p> <note> <p>A deleted Lambda function cannot be recovered. Ensure that you specify the correct function name and version before deleting.</p> </note> <p>To delete Lambda event source mappings that invoke a function, use <a>DeleteEventSourceMapping</a>. For Amazon Web Services services and resources that invoke your function directly, delete the trigger in the service where you originally configured it.</p>

    Args:
        function_name: <p>The name or ARN of the Lambda function or version.</p> <p class="title"> <b>Name formats</b> </p> <ul> <li> <p> <b>Function name</b> – <code>my-function</code> (name-only), <code>my-function:1</code> (with version).</p> </li> <li> <p> <b>Function ARN</b> – <code>arn:aws:lambda:us-west-2:123456789012:function:my-function</code>.</p> </li> <li> <p> <b>Partial ARN</b> – <code>123456789012:function:my-function</code>.</p> </li> </ul> <p>You can append a version number or alias to any of the formats. The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length.</p>
        qualifier: <p>Specify a version to delete. You can't delete a version that an alias references.</p>

    Raises:
        capo_lambda.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>One of the parameters in the request is not valid.</p>
        capo_lambda.errors.resource_conflict_exception.ResourceConflictException: <p>The resource already exists, or another operation is in progress.</p>
        capo_lambda.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource specified in the request does not exist.</p>
        capo_lambda.errors.service_exception.ServiceException: <p>The Lambda service encountered an internal error.</p>
        capo_lambda.errors.too_many_requests_exception.TooManyRequestsException: <p>The request throughput limit was exceeded. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html#api-requests">Lambda quotas</a>.</p>
        capo_lambda.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To delete a version of a Lambda function
        The following example deletes version 1 of a Lambda function named my-function.

        >>> client.delete_function(function_name='my-function', qualifier='1')
    """

    def _handler(
        req: "OperationRequest[capo_lambda.types.delete_function_request.DeleteFunctionRequest]",
    ) -> OperationResponse[
        "capo_lambda.types.delete_function_response.DeleteFunctionResponse"
    ]:
        import capo_lambda._operations.aws_gir_api_service.delete_function

        output, http_response = (
            capo_lambda._operations.aws_gir_api_service.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_lambda.types.delete_function_request.DeleteFunctionRequest = {
        "function_name": function_name
    }
    if qualifier is not None:
        input_["qualifier"] = qualifier

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