Create functions
You create a function in two stages:
-
Create the function code as JavaScript. You can use the default example from the CloudFront console or write your own. For more information, see the following topics:
-
Use CloudFront to create the function and include your code. The code exists inside the function (not as a reference).
After you create the function, it's added to the DEVELOPMENT stage. We
recommend that you test your function before you publish it. After you publish your function, the
function changes to the LIVE stage.
TaggingConflict error when creating functions
CloudFront Functions reuse ARNs for functions with the same name. You may encounter a
TaggingConflict (HTTP 409) error when creating a function with tags.
This can occur in the following scenarios:
-
After deleting a function – Recreating a function with the same name and tags immediately after deletion.
-
After a failed creation attempt – If a previous create request failed (for example, due to invalid parameters, invalid KVS association, or a failed CloudFormation stack rollback).
If you receive a TaggingConflict error, you can:
-
Wait a few minutes and retry the operation.
-
Use a different function name. This avoids the ARN reuse conflict entirely.
-
If your template creates both a KeyValueStore and a Function that references it, add an explicit
DependsOnto ensure the KVS is fully provisioned before the function is created.