Skip to content

How to empty S3 bucket without deleting it? #269

Closed

Description

@mdavis-xyz
SUMMARY

I want to delete the contents of an S3 bucket, without deleting the bucket itself.

My use case is that I have a CloudFormation stack with buckets and other resources.
I want to delete the stack. Amazon designed the AWS::S3::Bucket resource stupidly, so that CloudFormation will fail to delete a stack if it contains a non-empty bucket. So I want to empty the bucket myself, before deleting the stack.

ISSUE TYPE
  • Documentation Report
COMPONENT NAME

amazon.aws.aws_s3
aws_s3
amazon.aws.s3_bucket
s3_bucket

ANSIBLE VERSION

N/A

Notes

The documentation shows that I can empty and delete a bucket with:


- name: Delete a bucket and all contents
  amazon.aws.aws_s3:
    bucket: mybucket
    mode: delete

or

# Remove an S3 bucket and any keys it contains
- amazon.aws.s3_bucket:
    name: mys3bucket
    state: absent
    force: yes

Is there any way to tweak either of these using the existing module functionality to empty the bucket but not delete it?

Activity

  1. ansibullbot commented on Feb 25, 2021

    @ansibullbot

    Files identified in the description:

    If these files are inaccurate, please update the component name section of the description or use the !component bot command.

    click here for bot help

  2. ansibullbot commented on Feb 25, 2021

    @ansibullbot
  3. abikouo commented on Mar 3, 2021

    @abikouo
    Contributor

    Hi @mdavis-xyz , this is more a question of the mailing or IRC.
    I take the freedom to close the issue for now, and if needed you can re-open it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions