dcg

AWS S3

storage.s3

Protects against destructive S3 operations like bucket removal, recursive deletes, and sync --delete.

  • 6blocking rules
  • 10safe patterns
  • 2Critical
  • 3High
  • 1Medium
~/.config/dcg/config.toml
[packs]
enabled = ["storage.s3"]

Evaluated when a command contains s3, s3api, rb, delete-bucket, delete-object, delete-objects, --delete.

Blocking rules

Each rule ID is storage.s3:<name>. Use it in allowlists and [policy.rules].

  1. s3-rb

    Critical

    aws s3 rb removes an S3 bucket and is destructive.

    Explanation
    Removing an S3 bucket deletes the bucket and optionally all objects within it (with --force). Bucket names are globally unique and may be claimed by others after deletion. Versioned objects require additional cleanup. Safer alternatives: - aws s3 ls: Review bucket contents first - Empty the bucket before removal - Enable bucket versioning for recovery options
  2. s3api-delete-bucket

    Critical

    aws s3api delete-bucket permanently deletes a bucket.

    Explanation
    The delete-bucket API removes an S3 bucket. The bucket must be empty (including all versions and delete markers). Once deleted, the bucket name becomes available globally and may be claimed by others. Safer alternatives: - aws s3api list-objects-v2: Verify bucket is empty - aws s3api list-object-versions: Check for versions - Use lifecycle policies for managed cleanup
  3. s3-rm

    High

    aws s3 rm deletes S3 objects and is destructive.

    Explanation
    The rm command deletes objects from S3. With --recursive, it deletes all objects under a prefix. For versioned buckets, this creates delete markers; for unversioned buckets, data is permanently lost. Safer alternatives: - aws s3 ls: Review objects before deletion - Use --dryrun to preview what will be deleted - Enable versioning for recovery options
  4. s3-sync-delete

    High

    aws s3 sync --delete removes destination objects not in source.

    Explanation
    The --delete flag removes files from the destination that don't exist in the source. This can accidentally delete important data if source and destination are swapped or if source is empty. Safer alternatives: - aws s3 sync --dryrun: Preview changes first - Omit --delete for additive-only sync - Back up destination before syncing
  5. s3api-delete-objects

    High

    aws s3api delete-objects permanently deletes multiple objects.

    Explanation
    Batch deletion removes up to 1,000 objects per request. A malformed delete JSON file can remove unintended objects. Deletions are processed in parallel and cannot be easily stopped once started. Safer alternatives: - Review the delete JSON file carefully - Test with a single object first - Enable versioning before bulk deletions
  6. s3api-delete-object

    Medium

    aws s3api delete-object permanently deletes an object.

    Explanation
    Deleting an object removes it from S3. For versioned buckets, this creates a delete marker. Specifying a version-id permanently deletes that specific version. Unversioned objects are immediately and permanently deleted. Safer alternatives: - aws s3api head-object: Verify object exists - Use bucket versioning for recovery - Copy to backup location before deletion

Safe patterns

Checked first. A command that matches one is never blocked by this pack.

  • s3-list
  • s3-copy
  • s3-presign
  • s3-mb
  • s3-rm-dryrun
  • s3-sync-delete-dryrun
  • s3-sync-dryrun-delete
  • s3api-list-objects
  • s3api-get-object
  • s3api-head-object