Skip to main content

Delete Object

Deletes an object from an S3 bucket, optionally targeting a specific version.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • Client Id - The client connection ID from the Connect node. Optional if using credentials directly.
  • Bucket Name - The name of the S3 bucket containing the object to delete.
  • Object Name - The key/name of the object to delete, including any prefixes (folder path).
  • Version Id - (Optional) The version ID of a specific object version to delete. Used only with versioned buckets.

Options

  • End Point - S3 endpoint URL. Required only if using credentials directly instead of Client ID.
  • Access Key Id - AWS Access Key ID credential. Optional - use this instead of Client ID for direct authentication.
  • Secret Key Access - AWS Secret Access Key credential. Optional - use this instead of Client ID for direct authentication.

How It Works

The Delete Object node permanently removes an object from an S3 bucket. When executed, the node:

  1. Retrieves the S3 client using either the Client ID or creates a new client from credentials
  2. Validates that the bucket name and object name are provided and not empty
  3. Retrieves the optional version ID parameter
  4. Sends a request to S3 to delete the object (or specific version)
  5. Completes successfully once the object is deleted

Requirements

  • Either a valid Client ID from a Connect node, or Access Key ID and Secret Access Key credentials
  • A valid S3 bucket
  • Appropriate S3 permissions to delete objects (s3:DeleteObject)
  • For versioned objects, s3:DeleteObjectVersion permission

Error Handling

The node will return specific errors in the following cases:

  • Empty or invalid bucket name
  • Empty or invalid object name
  • Invalid Client ID or credentials
  • Bucket does not exist
  • Insufficient permissions to delete objects
  • Invalid version ID (if specified)
  • Network or connection errors

Usage Notes

  • Object deletion is permanent and cannot be undone
  • If the object doesn't exist, the operation succeeds without error (idempotent)
  • For non-versioned buckets, deletion removes the object completely
  • For versioned buckets without version ID, a delete marker is added (soft delete)
  • For versioned buckets with version ID, the specific version is permanently deleted
  • Deleting all versions of an object requires multiple delete operations
  • There is no confirmation prompt - deletion happens immediately

Versioning Behavior

Non-Versioned Buckets:

  • Object is permanently deleted
  • Object name becomes available for reuse immediately

Versioned Buckets (no Version ID specified):

  • A delete marker is created
  • Previous versions remain in the bucket
  • Object appears deleted but can be restored by removing the delete marker

Versioned Buckets (Version ID specified):

  • The specific version is permanently deleted
  • Other versions remain unchanged
  • Delete markers can be deleted by specifying their version ID

Best Practices

  • Verify the object name before deletion to avoid accidental data loss
  • Use Get Object to confirm the object exists before deleting
  • For important data, download a backup before deletion
  • Keep audit logs of deletion operations for compliance
  • Use bucket versioning to protect against accidental deletions
  • Implement deletion policies and approval workflows for production data
  • Consider using lifecycle policies for automated cleanup
  • Test deletion logic in a non-production environment first

Example

To delete a temporary file:

Inputs:

  • Client Id: (from Connect node)
  • Bucket Name: temp-uploads
  • Object Name: uploads/temp-file-12345.pdf

Result: The object uploads/temp-file-12345.pdf will be permanently deleted from the bucket.

Delete Specific Version

To delete a specific version of an object:

Inputs:

  • Client Id: (from Connect node)
  • Bucket Name: versioned-documents
  • Object Name: contracts/agreement.pdf
  • Version Id: XYZ123VersionID

Result: Only the specified version will be deleted; other versions remain intact.

Batch Delete Example

To delete multiple objects, use a Loop node:

  1. List Objects - Get all objects to delete
  2. Loop - For each object:
    • Delete Object
    • Object Name: (from loop item)

Example with filtering:

// Get objects older than 30 days
const thirtyDaysAgo = new Date();
thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30);

const oldObjects = objects.filter(obj =>
new Date(obj.LastModified) < thirtyDaysAgo
);

Common Use Cases

Cleanup Temporary Files Delete temporary or cache files after processing:

  1. Process File - Complete file processing
  2. Delete Object - Remove temporary file from S3

Data Retention Compliance Delete files that exceed retention periods:

  1. List Objects - Get all objects
  2. Filter by Date - Identify expired objects
  3. Loop and Delete - Remove expired files

Failed Upload Cleanup Clean up partially uploaded or failed uploads:

  1. Detect Failed Upload - Error in upload process
  2. Delete Object - Remove incomplete file
  3. Retry Upload - Attempt upload again

Storage Cost Optimization Delete unused or duplicate files to reduce storage costs:

  1. Analyze Usage - Identify unused files
  2. Delete Unused Objects - Remove unnecessary files
  3. Monitor Storage Costs - Track cost savings

Conditional Delete Example

Delete only if file is older than a certain date:

  1. Get Object - Get object metadata
  2. Check Date - Compare LastModified date
  3. Conditional Delete - Delete if older than threshold
const metadata = result; // From Get Object
const fileDate = new Date(metadata.LastModified);
const cutoffDate = new Date('2024-01-01');

if (fileDate < cutoffDate) {
// Proceed with deletion
}

Direct Credentials Example

Inputs:

  • Bucket Name: my-data
  • Object Name: old-reports/report-2023.pdf

Options:

  • End Point: s3.us-east-1.amazonaws.com
  • Access Key Id: (your AWS Access Key ID credential)
  • Secret Key Access: (your AWS Secret Access Key credential)

Deleting "Folders"

S3 doesn't have true folders, but you can delete all objects with a common prefix:

  1. List Objects with prefix filter
  2. Loop through results
  3. Delete each object

Example to delete all objects in "folder":

  1. List Objects with prefix: documents/2023/
  2. Delete each object returned

Versioned Bucket Complete Cleanup

To completely remove an object from a versioned bucket:

  1. List Object Versions - Get all versions and delete markers
  2. Loop through versions - For each version:
    • Delete Object with version ID
  3. Object is now completely removed

Safety Measures

Pre-Deletion Checklist:

  1. Verify bucket name is correct
  2. Confirm object name/path is correct
  3. Check if object is critical or can be recreated
  4. Ensure backups exist if needed
  5. Verify you have proper permissions
  6. Test in non-production environment first

Common Errors

Error: "Access Denied"

  • Solution: Ensure your credentials have the s3:DeleteObject permission

Error: "NoSuchBucket: The specified bucket does not exist"

  • Solution: Verify the bucket name is correct

Error: "Invalid version id specified"

  • Solution: Check that the version ID format is correct and the version exists

Error: "Empty or invalid object name"

  • Solution: Ensure the object name is provided and not an empty string

Idempotent Behavior

Delete Object is idempotent - deleting a non-existent object succeeds:

First call: Deletes the object (if exists)
Second call: Succeeds even though object is already deleted

This is useful for cleanup operations where you want to ensure an object is deleted regardless of its current state.

Performance Tips

  • Batch deletions by processing multiple objects in parallel
  • Use lifecycle policies for automatic deletion based on rules
  • For large-scale deletions, consider AWS S3 Batch Operations
  • Monitor deletion rate to avoid throttling
  • Delete during off-peak hours for large cleanup operations