> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/action-center/aws/delete-files-from-s3-bucket.md).

# Delete Files from S3 Bucket

Deletes the object keys you list from every S3 bucket that the workflow passes to it. The same list of keys is applied to every bucket.

{% hint style="danger" %}
Deleted objects cannot be restored by this job. Check that the saved query returns only the buckets you mean, because every bucket gets the same key list.
{% endhint %}

### Before you begin

* AWS credentials (access key ID and secret access key) that are allowed to call the AWS API actions listed below. Enter them in the node or save them once in [Action Center Settings](broken://pages/ea41765c908dc2733f18c3a1329cd7501b60f6da) (the **AWS** group has one tab per job, so each job needs its own defaults).
* Asset type: `service` only. Only service assets whose `ServiceType` is `object_storage` are used.
* Required columns: `Name` and `ServiceType`. `Name` is used as the S3 bucket name.
* AWS API actions the job calls: `DeleteObjects` (S3).

### Settings

The node form shows these fields. Field labels are generated from the field names, so they appear as listed here. The AWS access key ID and secret access key are plain text fields, not masked fields.

| Setting               | Type             | Required | Default | Description                                                                                                                                                                                                                            |
| --------------------- | ---------------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Aws access key id     | Text             | Yes      | None    | AWS access key ID the job signs its requests with. Not masked in the form or in Settings.                                                                                                                                              |
| Aws secret access key | Text             | Yes      | None    | Secret access key for the key ID above. Not masked in the form or in Settings.                                                                                                                                                         |
| Aws region            | Text             | Yes      | None    | AWS region the client connects to, for example `eu-west-1`. The value may be empty.                                                                                                                                                    |
| Object Keys           | Long text (JSON) | No       | `[]`    | JSON array of object keys, for example `["folder/file1.txt", "logs/2024.log"]`. Anything that is not an array of strings is rejected. An empty array is also rejected with `keys cannot be empty`, so you must enter at least one key. |

### How it works

The job takes the `Name` of every incoming service asset whose `ServiceType` is `object_storage` and treats each as a bucket. If there are none, the job fails with `No S3 buckets found in selected assets`.

For each bucket the job sends the keys with `DeleteObjects`, in batches of 1000 keys. It writes the number of deleted objects and errors to the run log, and each per-object error (key, code, message) as a warning. Per-object errors do not fail the job.

If an AWS call fails for a bucket, the job fails with `AWS S3 delete objects failed for bucket <name>`. Buckets handled before it are already cleaned and later buckets are not processed.

The job does not change the asset data. It passes the incoming assets unchanged to the next node.

### Example

Put the job after a condition node (Service inventory) whose saved query returns the buckets to clean.

| Setting               | Value                                           |
| --------------------- | ----------------------------------------------- |
| Aws access key id     | `YOUR_AWS_ACCESS_KEY_ID`                        |
| Aws secret access key | `YOUR_AWS_SECRET_ACCESS_KEY`                    |
| Aws region            | `eu-west-1`                                     |
| Object Keys           | `["exports/old-report.csv", "tmp/scratch.txt"]` |

### Related jobs

Other S3 jobs: [Add Tags to S3 Bucket](broken://pages/652755eb6447754c9d289a442962c627a9266592) and [Enable S3 Bucket Encryption (AES256)](broken://pages/a85acfc01775ba3b3ccbb5b9289138fbfa0d0586).

### What's next?

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>About Action Center</strong></td><td>Workflows, triggers, conditions and job nodes.</td><td><a href="broken://pages/94a9962c87c4d45ae1ec3bb263b516656f67490d">Broken link</a></td></tr><tr><td><strong>Action Center Settings</strong></td><td>Save the AWS connection values as job defaults.</td><td><a href="broken://pages/ea41765c908dc2733f18c3a1329cd7501b60f6da">Broken link</a></td></tr><tr><td><strong>Add Tags to S3 Bucket</strong></td><td>A related AWS job.</td><td><a href="broken://pages/652755eb6447754c9d289a442962c627a9266592">Broken link</a></td></tr></tbody></table>

{% hint style="info" %}
Available starting from version 6.5.0.
{% endhint %}
