From 67cf2da2a1a0007915cc99c77c72616e6c29d478 Mon Sep 17 00:00:00 2001 From: Sloane Hertel Date: Wed, 18 Jul 2018 13:13:33 -0400 Subject: [PATCH] Fix error when removing S3 lifecycle rules (#42762) --- lib/ansible/modules/cloud/amazon/s3_lifecycle.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/s3_lifecycle.py b/lib/ansible/modules/cloud/amazon/s3_lifecycle.py index e4c2a87258..2acd5d15b8 100644 --- a/lib/ansible/modules/cloud/amazon/s3_lifecycle.py +++ b/lib/ansible/modules/cloud/amazon/s3_lifecycle.py @@ -415,8 +415,9 @@ def destroy_lifecycle_rule(client, module): try: if lifecycle_obj['Rules']: client.put_bucket_lifecycle_configuration(Bucket=name, LifecycleConfiguration=lifecycle_obj) - else: - client.delete_lifecycle_configuration(Bucket=name) + elif current_lifecycle_rules: + changed = True + client.delete_bucket_lifecycle(Bucket=name) except (ClientError, BotoCoreError) as e: module.fail_json_aws(e) module.exit_json(changed=changed)