Skip to main content

lifecycle

Creates, updates, deletes, gets or lists a lifecycle resource.

Overview​

Namelifecycle
TypeResource
Idcloudflare.r2.lifecycle

Fields​

The following fields are returned by SELECT queries:

Success Response.

NameDatatypeDescription
idstringUnique identifier for this rule. (example: Expire all objects older than 24 hours)
abortMultipartUploadsTransitionobjectTransition to abort ongoing multipart uploads.
conditionsobjectConditions that apply to all transitions of this rule.
deleteObjectsTransitionobjectTransition to delete objects.
enabledbooleanWhether or not this rule is in effect.
storageClassTransitionsarrayTransitions to change the storage class of objects.

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectbucket_name, account_idcf-r2-jurisdictionGet object lifecycle rules for a bucket.
updatereplacebucket_name, account_idcf-r2-jurisdictionSet the object lifecycle rules for a bucket.

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
account_idstringThe Cloudflare account ID.
bucket_namestringThe R2 bucket name.
cf-r2-jurisdictionstring

SELECT examples​

Get object lifecycle rules for a bucket.

SELECT
id,
abortMultipartUploadsTransition,
conditions,
deleteObjectsTransition,
enabled,
storageClassTransitions
FROM cloudflare.r2.lifecycle
WHERE bucket_name = '{{ bucket_name }}' -- required
AND account_id = '{{ account_id }}' -- required
AND cf-r2-jurisdiction = '{{ cf-r2-jurisdiction }}'
;

REPLACE examples​

Set the object lifecycle rules for a bucket.

REPLACE cloudflare.r2.lifecycle
SET
rules = '{{ rules }}'
WHERE
bucket_name = '{{ bucket_name }}' --required
AND account_id = '{{ account_id }}' --required
AND cf-r2-jurisdiction = '{{ cf-r2-jurisdiction}}'
RETURNING
errors,
messages,
result,
success;