- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
DeleteFunctionCommand
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
.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { CloudFrontClient, DeleteFunctionCommand } from "@aws-sdk/client-cloudfront"; // ES Modules import
// const { CloudFrontClient, DeleteFunctionCommand } = require("@aws-sdk/client-cloudfront"); // CommonJS import
const client = new CloudFrontClient(config);
const input = { // DeleteFunctionRequest
Name: "STRING_VALUE", // required
IfMatch: "STRING_VALUE", // required
};
const command = new DeleteFunctionCommand(input);
const response = await client.send(command);
// {};
DeleteFunctionCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
IfMatch Required | string | undefined | The current version ( |
Name Required | string | undefined | The name of the function that you are deleting. |
DeleteFunctionCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
FunctionInUse | client | Cannot delete the function because it's attached to one or more cache behaviors. |
InvalidIfMatchVersion | client | The |
NoSuchFunctionExists | client | The function does not exist. |
PreconditionFailed | client | The precondition in one or more of the request fields evaluated to |
UnsupportedOperation | client | This operation is not supported in this Amazon Web Services Region. |
CloudFrontServiceException | Base exception class for all service exceptions from CloudFront service. |