Cloudflare R2 icon

Cloudflare R2

Store and retrieve objects from Cloudflare R2

Overview

This node integrates with Cloudflare R2, a scalable object storage service compatible with the S3 API. Specifically, the "Bucket - Delete" operation allows users to delete an existing R2 bucket by specifying its unique name. This operation is useful for managing storage resources, cleaning up unused buckets, or automating infrastructure lifecycle tasks.

Typical use cases include:

  • Automating cleanup of empty buckets in Cloudflare R2.
  • Managing bucket lifecycle as part of CI/CD pipelines.
  • Integrating bucket deletion into broader workflows that manage cloud storage resources.

Example: A user wants to delete a bucket named "my-archive-bucket" after migrating data elsewhere. They configure this node with the bucket name and execute it to remove the bucket from their Cloudflare R2 account.

Properties

Name Meaning
Bucket Name The globally unique name of the R2 bucket to delete. Must be specified to identify the bucket.

Output

The node outputs JSON objects indicating the success status of the deletion operation. For each input item processed, the output contains:

  • success: Boolean indicating whether the bucket was successfully deleted.
  • bucket: The name of the bucket targeted for deletion.

If the deletion fails due to the bucket not being empty, the node throws a descriptive error explaining that all objects (including hidden files and incomplete multipart uploads) must be removed before deletion.

No binary data is output by this operation.

Dependencies

  • Requires valid Cloudflare API credentials configured with "R2 S3-Compatible" authentication mode.
  • The credentials must include:
    • Account ID
    • R2 Access Key ID
    • R2 Secret Access Key
  • The node uses AWS SDK v3 S3 client internally, configured to communicate with Cloudflare R2 endpoints.
  • No additional environment variables are required beyond the configured credentials.

Troubleshooting

Common Issues

  • Bucket Not Empty Error: Attempting to delete a bucket that still contains objects or incomplete uploads will fail with HTTP 409 Conflict. The error message advises ensuring the bucket is completely empty before deletion.
  • Invalid Credentials: If the R2 credentials are missing or invalid, the node will throw an error instructing to verify the Cloudflare API key configuration and ensure the "R2 S3-Compatible" auth mode is selected.
  • Bucket Name Format: The bucket name must be globally unique and cannot contain invalid characters such as slashes (/). Invalid names may cause request failures.

Error Messages

  • "Cannot delete bucket '<bucketName>': Bucket must be completely empty before deletion. Please ensure all objects, including hidden files and incomplete multipart uploads, are removed first. You may need to check the bucket manually in the Cloudflare dashboard."
    • Resolution: Empty the bucket fully before retrying deletion.
  • "R2 credentials are missing or invalid. Please check your Cloudflare API credentials configuration."
    • Resolution: Verify that the API token and R2 keys are correctly set in the node credentials.
  • "Bucket name shouldn't contain '/', received '<bucketName>'"
    • Resolution: Use a valid bucket name without slashes.

Links and References


Summary of execute() logic for Resource "Bucket" and Operation "Delete"

  • Retrieves the bucket name parameter from the node input.
  • Obtains Cloudflare R2 credentials from the configured credential store.
  • Validates presence of necessary R2 credentials (access key, secret key, endpoint).
  • Constructs an HTTP DELETE request to the R2 bucket endpoint using AWS Signature V4 signing.
  • Sends the request to delete the specified bucket.
  • If the response indicates success, returns JSON { success: true, bucket: <bucketName> }.
  • If the bucket is not empty (HTTP 409), throws a specific error advising to empty the bucket first.
  • Handles other errors by throwing them or returning error details if "continue on fail" is enabled.

This operation directly deletes the entire bucket resource in Cloudflare R2 and requires the bucket to be empty beforehand.

Discussion