Repository: cloud-custodian/cloud-custodian

Issue:
S3 bucket configure-lifecycle action
### Describe the bug

A lot of our legacy accounts have pretty old lifecycle rules set on them. When trying to get rid of them, via custodian, we're running into this error
```
    if rule['ID'] == existing_rule['ID']:
TypeError: 'NoneType' object is not subscriptable
2022-06-09 14:49:06,029: custodian.commands:ERROR The following policies had errors while executing
```
Tried to debug it on a bucket by bucket basis, but there seems to be a lot of them running into this issue.



### What did you expect to happen?

Expected behavior would be to remove those lifecycle policies.

### Cloud Provider

Amazon Web Services (AWS)

### Cloud Custodian version and dependency information

```shell
Latest version of custodian
```


### Policy

```shell
Sample policy used:


- name: s3-fix2
    resource: s3
    conditions:
      - type: value
        key: region
        op: in
        value: [ 'us-east-1' ]
    description: |
      This policy applies the lifecycle transitions and expiration policies to each bucket for enabling the data retention process.
    filters:
      - type: value
        key: Name
        op: in
        value: ['test', 'test-1']
    actions:
      - type: configure-lifecycle
        rules:
          - ID: lc-policy-1
            Status: absent
          - ID: lc-policy-2
            Status: absent
 ```
```


### Relevant log/traceback output

```shell
if rule['ID'] == existing_rule['ID']:
TypeError: 'NoneType' object is not subscriptable
2022-06-09 14:49:06,029: custodian.commands:ERROR The following policies had errors while executing
```


### Extra information or context

_No response_


Discussion:

Resolving patch:
diff --git a/c7n/resources/s3.py b/c7n/resources/s3.py
--- a/c7n/resources/s3.py
+++ b/c7n/resources/s3.py
@@ -3113,6 +3113,8 @@ def process_bucket(self, bucket):
         config = (bucket.get('Lifecycle') or {}).get('Rules', [])
         for rule in self.data['rules']:
             for index, existing_rule in enumerate(config):
+                if not existing_rule:
+                    continue
                 if rule['ID'] == existing_rule['ID']:
                     if rule['Status'] == 'absent':
                         config[index] = None


Test patch:
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.CreateBucket_1.json b/tests/data/placebo/test_s3_lifecycle/s3.CreateBucket_1.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.CreateBucket_1.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.CreateBucket_1.json
@@ -1,20 +1,7 @@
 {
-    "status_code": 200, 
+    "status_code": 200,
     "data": {
-        "Location": "/custodian-lifecycle-test", 
-        "ResponseMetadata": {
-            "HTTPStatusCode": 200, 
-            "RetryAttempts": 0, 
-            "HostId": "ymLGyadwFGttyvSvJ8Gz4y+32lmbtpDWn9krWebykBkTs+Nwr4Jb9yddHXRra8dtAGqnHgJr9Y4=", 
-            "RequestId": "D438BA28F50758AD", 
-            "HTTPHeaders": {
-                "content-length": "0", 
-                "x-amz-id-2": "ymLGyadwFGttyvSvJ8Gz4y+32lmbtpDWn9krWebykBkTs+Nwr4Jb9yddHXRra8dtAGqnHgJr9Y4=", 
-                "server": "AmazonS3", 
-                "x-amz-request-id": "D438BA28F50758AD", 
-                "location": "/custodian-lifecycle-test", 
-                "date": "Fri, 27 Oct 2017 19:53:49 GMT"
-            }
-        }
+        "ResponseMetadata": {},
+        "Location": "/c7n-lifecycle-test-again3"
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.DeleteBucket_1.json b/tests/data/placebo/test_s3_lifecycle/s3.DeleteBucket_1.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.DeleteBucket_1.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.DeleteBucket_1.json
@@ -1,17 +1,6 @@
 {
-    "status_code": 204, 
+    "status_code": 204,
     "data": {
-        "ResponseMetadata": {
-            "HTTPStatusCode": 204, 
-            "RetryAttempts": 0, 
-            "HostId": "l+vTrQHOFVjiKh+od/0chg12r1DveQa48pK1u6VNy06noJOiNp63J2nY7D7ocxAeeyFvctPezKI=", 
-            "RequestId": "64ABD36E173BECBC", 
-            "HTTPHeaders": {
-                "x-amz-id-2": "l+vTrQHOFVjiKh+od/0chg12r1DveQa48pK1u6VNy06noJOiNp63J2nY7D7ocxAeeyFvctPezKI=", 
-                "date": "Fri, 27 Oct 2017 19:54:28 GMT", 
-                "x-amz-request-id": "64ABD36E173BECBC", 
-                "server": "AmazonS3"
-            }
-        }
+        "ResponseMetadata": {}
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_1.json b/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_1.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_1.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_1.json
@@ -1,24 +1,11 @@
 {
-    "status_code": 404, 
+    "status_code": 404,
     "data": {
-        "ResponseMetadata": {
-            "HTTPStatusCode": 404, 
-            "RetryAttempts": 0, 
-            "HostId": "+8K3KViipaL35JEmKmxb1R0jrEOW+/ZGu/BUyfjOH1Yff0kacK2k0n442A1qz/0NTnj6+g62yms=", 
-            "RequestId": "31954E321EF36581", 
-            "HTTPHeaders": {
-                "x-amz-id-2": "+8K3KViipaL35JEmKmxb1R0jrEOW+/ZGu/BUyfjOH1Yff0kacK2k0n442A1qz/0NTnj6+g62yms=", 
-                "server": "AmazonS3", 
-                "transfer-encoding": "chunked", 
-                "x-amz-request-id": "31954E321EF36581", 
-                "date": "Fri, 27 Oct 2017 19:53:49 GMT", 
-                "content-type": "application/xml"
-            }
-        }, 
         "Error": {
-            "Message": "The lifecycle configuration does not exist", 
-            "Code": "NoSuchLifecycleConfiguration", 
-            "BucketName": "custodian-lifecycle-test"
-        }
+            "Code": "NoSuchLifecycleConfiguration",
+            "Message": "The lifecycle configuration does not exist",
+            "BucketName": "c7n-lifecycle-test-again3"
+        },
+        "ResponseMetadata": {}
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_2.json b/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_2.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_2.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_2.json
@@ -1,31 +1,21 @@
 {
-    "status_code": 200, 
+    "status_code": 200,
     "data": {
+        "ResponseMetadata": {},
         "Rules": [
             {
-                "Status": "Enabled", 
-                "Prefix": "foo/", 
+                "ID": "test-lifecycle",
+                "Filter": {
+                    "Prefix": "foo/"
+                },
+                "Status": "Enabled",
                 "Transitions": [
                     {
-                        "Days": 60, 
+                        "Days": 60,
                         "StorageClass": "GLACIER"
                     }
-                ], 
-                "ID": "test-lifecycle"
+                ]
             }
-        ], 
-        "ResponseMetadata": {
-            "HTTPStatusCode": 200, 
-            "RetryAttempts": 0, 
-            "HostId": "3qQlL4u3lmjM+9l+BzhPKFZfNADu56RgOaFWTpxKrIxYEXx9/YStIuWDKmqrkcGQhoC/hAIYCvw=", 
-            "RequestId": "21DF87BD43B3E42D", 
-            "HTTPHeaders": {
-                "x-amz-id-2": "3qQlL4u3lmjM+9l+BzhPKFZfNADu56RgOaFWTpxKrIxYEXx9/YStIuWDKmqrkcGQhoC/hAIYCvw=", 
-                "date": "Fri, 27 Oct 2017 19:53:58 GMT", 
-                "transfer-encoding": "chunked", 
-                "x-amz-request-id": "21DF87BD43B3E42D", 
-                "server": "AmazonS3"
-            }
-        }
+        ]
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_3.json b/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_3.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_3.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_3.json
@@ -1,31 +1,21 @@
 {
-    "status_code": 200, 
+    "status_code": 200,
     "data": {
+        "ResponseMetadata": {},
         "Rules": [
             {
-                "Status": "Enabled", 
-                "Prefix": "foo/", 
+                "ID": "test-lifecycle",
+                "Filter": {
+                    "Prefix": "foo/"
+                },
+                "Status": "Enabled",
                 "Transitions": [
                     {
-                        "Days": 60, 
+                        "Days": 60,
                         "StorageClass": "GLACIER"
                     }
-                ], 
-                "ID": "test-lifecycle"
+                ]
             }
-        ], 
-        "ResponseMetadata": {
-            "HTTPStatusCode": 200, 
-            "RetryAttempts": 0, 
-            "HostId": "5DbaZ79TOAoS0jNqGgRzcIViGSugmWBwroU/9+18mpCln05N5NxBnpgcLsUqTZCj90/ABg1eI30=", 
-            "RequestId": "0EE3B0EEE721ACDD", 
-            "HTTPHeaders": {
-                "x-amz-id-2": "5DbaZ79TOAoS0jNqGgRzcIViGSugmWBwroU/9+18mpCln05N5NxBnpgcLsUqTZCj90/ABg1eI30=", 
-                "date": "Fri, 27 Oct 2017 19:54:00 GMT", 
-                "transfer-encoding": "chunked", 
-                "x-amz-request-id": "0EE3B0EEE721ACDD", 
-                "server": "AmazonS3"
-            }
-        }
+        ]
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_4.json b/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_4.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_4.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_4.json
@@ -1,42 +1,34 @@
 {
-    "status_code": 200, 
+    "status_code": 200,
     "data": {
+        "ResponseMetadata": {},
         "Rules": [
             {
-                "Status": "Enabled", 
-                "Prefix": "foo/", 
+                "ID": "test-lifecycle",
+                "Filter": {
+                    "Prefix": "foo/"
+                },
+                "Status": "Enabled",
                 "Transitions": [
                     {
-                        "Days": 60, 
+                        "Days": 60,
                         "StorageClass": "GLACIER"
                     }
-                ], 
-                "ID": "test-lifecycle"
-            }, 
+                ]
+            },
             {
-                "Status": "Enabled", 
-                "Prefix": "bar/", 
+                "ID": "test-lifecycle-two",
+                "Filter": {
+                    "Prefix": "bar/"
+                },
+                "Status": "Enabled",
                 "Transitions": [
                     {
-                        "Days": 60, 
+                        "Days": 60,
                         "StorageClass": "GLACIER"
                     }
-                ], 
-                "ID": "test-lifecycle-two"
+                ]
             }
-        ], 
-        "ResponseMetadata": {
-            "HTTPStatusCode": 200, 
-            "RetryAttempts": 0, 
-            "HostId": "lw3oEiVwReVqJvnKHUjuxjycat5ZBx2XV0I47KLE834kD37NbqnrEWWRTtFRi1+VpAsk/RRlPbw=", 
-            "RequestId": "AFDCFB67E27E0E5E", 
-            "HTTPHeaders": {
-                "x-amz-id-2": "lw3oEiVwReVqJvnKHUjuxjycat5ZBx2XV0I47KLE834kD37NbqnrEWWRTtFRi1+VpAsk/RRlPbw=", 
-                "date": "Fri, 27 Oct 2017 19:54:08 GMT", 
-                "transfer-encoding": "chunked", 
-                "x-amz-request-id": "AFDCFB67E27E0E5E", 
-                "server": "AmazonS3"
-            }
-        }
+        ]
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_5.json b/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_5.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_5.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_5.json
@@ -1,42 +1,34 @@
 {
-    "status_code": 200, 
+    "status_code": 200,
     "data": {
+        "ResponseMetadata": {},
         "Rules": [
             {
-                "Status": "Enabled", 
-                "Prefix": "foo/", 
+                "ID": "test-lifecycle",
+                "Filter": {
+                    "Prefix": "foo/"
+                },
+                "Status": "Enabled",
                 "Transitions": [
                     {
-                        "Days": 60, 
+                        "Days": 60,
                         "StorageClass": "GLACIER"
                     }
-                ], 
-                "ID": "test-lifecycle"
-            }, 
+                ]
+            },
             {
-                "Status": "Enabled", 
-                "Prefix": "bar/", 
+                "ID": "test-lifecycle-two",
+                "Filter": {
+                    "Prefix": "bar/"
+                },
+                "Status": "Enabled",
                 "Transitions": [
                     {
-                        "Days": 60, 
+                        "Days": 60,
                         "StorageClass": "GLACIER"
                     }
-                ], 
-                "ID": "test-lifecycle-two"
+                ]
             }
-        ], 
-        "ResponseMetadata": {
-            "HTTPStatusCode": 200, 
-            "RetryAttempts": 0, 
-            "HostId": "6/FcZqvpCpYW0MX9YV+uyoa198urHucqDqVwelqc43mwJXEKc+9UG2rJRaU7bykFaKTmIEcRdmE=", 
-            "RequestId": "16B87B6AF81A90BE", 
-            "HTTPHeaders": {
-                "x-amz-id-2": "6/FcZqvpCpYW0MX9YV+uyoa198urHucqDqVwelqc43mwJXEKc+9UG2rJRaU7bykFaKTmIEcRdmE=", 
-                "date": "Fri, 27 Oct 2017 19:54:10 GMT", 
-                "transfer-encoding": "chunked", 
-                "x-amz-request-id": "16B87B6AF81A90BE", 
-                "server": "AmazonS3"
-            }
-        }
+        ]
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_6.json b/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_6.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_6.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_6.json
@@ -1,42 +1,34 @@
 {
-    "status_code": 200, 
+    "status_code": 200,
     "data": {
+        "ResponseMetadata": {},
         "Rules": [
             {
-                "Status": "Enabled", 
-                "Prefix": "foo/", 
+                "ID": "test-lifecycle",
+                "Filter": {
+                    "Prefix": "foo/"
+                },
+                "Status": "Enabled",
                 "Transitions": [
                     {
-                        "Days": 60, 
+                        "Days": 60,
                         "StorageClass": "GLACIER"
                     }
-                ], 
-                "ID": "test-lifecycle"
-            }, 
+                ]
+            },
             {
-                "Status": "Enabled", 
-                "Prefix": "baz/", 
+                "ID": "test-lifecycle-two",
+                "Filter": {
+                    "Prefix": "baz/"
+                },
+                "Status": "Enabled",
                 "Transitions": [
                     {
-                        "Days": 60, 
+                        "Days": 60,
                         "StorageClass": "GLACIER"
                     }
-                ], 
-                "ID": "test-lifecycle-two"
+                ]
             }
-        ], 
-        "ResponseMetadata": {
-            "HTTPStatusCode": 200, 
-            "RetryAttempts": 0, 
-            "HostId": "lE6sPm3MS7thkssddcTbzkt0dw75SLZNOcFmx8svz0iwcJfcac0pEHPFMwc0q5I5c2sqar1T6WQ=", 
-            "RequestId": "5A00BC0579C3765D", 
-            "HTTPHeaders": {
-                "x-amz-id-2": "lE6sPm3MS7thkssddcTbzkt0dw75SLZNOcFmx8svz0iwcJfcac0pEHPFMwc0q5I5c2sqar1T6WQ=", 
-                "date": "Fri, 27 Oct 2017 19:54:18 GMT", 
-                "transfer-encoding": "chunked", 
-                "x-amz-request-id": "5A00BC0579C3765D", 
-                "server": "AmazonS3"
-            }
-        }
+        ]
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_7.json b/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_7.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_7.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_7.json
@@ -1,42 +1,34 @@
 {
-    "status_code": 200, 
+    "status_code": 200,
     "data": {
+        "ResponseMetadata": {},
         "Rules": [
             {
-                "Status": "Enabled", 
-                "Prefix": "foo/", 
+                "ID": "test-lifecycle",
+                "Filter": {
+                    "Prefix": "foo/"
+                },
+                "Status": "Enabled",
                 "Transitions": [
                     {
-                        "Days": 60, 
+                        "Days": 60,
                         "StorageClass": "GLACIER"
                     }
-                ], 
-                "ID": "test-lifecycle"
-            }, 
+                ]
+            },
             {
-                "Status": "Enabled", 
-                "Prefix": "baz/", 
+                "ID": "test-lifecycle-two",
+                "Filter": {
+                    "Prefix": "baz/"
+                },
+                "Status": "Enabled",
                 "Transitions": [
                     {
-                        "Days": 60, 
+                        "Days": 60,
                         "StorageClass": "GLACIER"
                     }
-                ], 
-                "ID": "test-lifecycle-two"
+                ]
             }
-        ], 
-        "ResponseMetadata": {
-            "HTTPStatusCode": 200, 
-            "RetryAttempts": 0, 
-            "HostId": "ccJil5cFHeX8EbJJiJDc7qeujdmnPnD14mXuKLeLFpFkP/QP5ICxXeL1sJ9L3K4HLoqtHLRPlFQ=", 
-            "RequestId": "23B7DAD8DE0600AE", 
-            "HTTPHeaders": {
-                "x-amz-id-2": "ccJil5cFHeX8EbJJiJDc7qeujdmnPnD14mXuKLeLFpFkP/QP5ICxXeL1sJ9L3K4HLoqtHLRPlFQ=", 
-                "date": "Fri, 27 Oct 2017 19:54:20 GMT", 
-                "transfer-encoding": "chunked", 
-                "x-amz-request-id": "23B7DAD8DE0600AE", 
-                "server": "AmazonS3"
-            }
-        }
+        ]
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_8.json b/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_8.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_8.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.GetBucketLifecycleConfiguration_8.json
@@ -1,31 +1,21 @@
 {
-    "status_code": 200, 
+    "status_code": 200,
     "data": {
+        "ResponseMetadata": {},
         "Rules": [
             {
-                "Status": "Enabled", 
-                "Prefix": "baz/", 
+                "ID": "test-lifecycle-two",
+                "Filter": {
+                    "Prefix": "baz/"
+                },
+                "Status": "Enabled",
                 "Transitions": [
                     {
-                        "Days": 60, 
+                        "Days": 60,
                         "StorageClass": "GLACIER"
                     }
-                ], 
-                "ID": "test-lifecycle-two"
+                ]
             }
-        ], 
-        "ResponseMetadata": {
-            "HTTPStatusCode": 200, 
-            "RetryAttempts": 0, 
-            "HostId": "Sy3deYoXDWQD5fHxTdOHlCEzW61BzTOYxkDUFF4xz7zxsN7sQWxLHCWHDdY3qB2NGRDUzoC2/QM=", 
-            "RequestId": "AB0E3BC9FEB5A7E9", 
-            "HTTPHeaders": {
-                "x-amz-id-2": "Sy3deYoXDWQD5fHxTdOHlCEzW61BzTOYxkDUFF4xz7zxsN7sQWxLHCWHDdY3qB2NGRDUzoC2/QM=", 
-                "date": "Fri, 27 Oct 2017 19:54:28 GMT", 
-                "transfer-encoding": "chunked", 
-                "x-amz-request-id": "AB0E3BC9FEB5A7E9", 
-                "server": "AmazonS3"
-            }
-        }
+        ]
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_1.json b/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_1.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_1.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_1.json
@@ -1,38 +1,25 @@
 {
-    "status_code": 200, 
+    "status_code": 200,
     "data": {
-        "Owner": {
-            "DisplayName": "mandeep.bal", 
-            "ID": "e7c8bb65a5fc49cf906715eae09de9e4bb7861a96361ba79b833aa45f6833b15"
-        }, 
+        "ResponseMetadata": {},
         "Buckets": [
             {
+                "Name": "c7n-lifecycle-test-again3",
                 "CreationDate": {
-                    "hour": 19, 
-                    "__class__": "datetime", 
-                    "month": 10, 
-                    "second": 49, 
-                    "microsecond": 0, 
-                    "year": 2017, 
-                    "day": 27, 
-                    "minute": 53
-                }, 
-                "Name": "custodian-lifecycle-test"
-            }
-        ], 
-        "ResponseMetadata": {
-            "HTTPStatusCode": 200, 
-            "RetryAttempts": 0, 
-            "HostId": "ZhO5p/MhQbG3f6HiQkeD6jtAE1+dPBjNsbh//JZepm4kyJr0tdiJOF2JfHUpSxOiYFhOefOpq98=", 
-            "RequestId": "8346B0ADDB374F19", 
-            "HTTPHeaders": {
-                "x-amz-id-2": "ZhO5p/MhQbG3f6HiQkeD6jtAE1+dPBjNsbh//JZepm4kyJr0tdiJOF2JfHUpSxOiYFhOefOpq98=", 
-                "server": "AmazonS3", 
-                "transfer-encoding": "chunked", 
-                "x-amz-request-id": "8346B0ADDB374F19", 
-                "date": "Fri, 27 Oct 2017 19:53:49 GMT", 
-                "content-type": "application/xml"
+                    "__class__": "datetime",
+                    "year": 2022,
+                    "month": 6,
+                    "day": 15,
+                    "hour": 2,
+                    "minute": 55,
+                    "second": 59,
+                    "microsecond": 0
+                }
             }
+        ],
+        "Owner": {
+            "DisplayName": "mandeep.bal",
+            "ID": "e7c8bb65a5fc49cf906715eae09de9e4bb7861a96361ba79b833aa45f6833b15"
         }
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_2.json b/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_2.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_2.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_2.json
@@ -1,38 +1,25 @@
 {
-    "status_code": 200, 
+    "status_code": 200,
     "data": {
-        "Owner": {
-            "DisplayName": "mandeep.bal", 
-            "ID": "e7c8bb65a5fc49cf906715eae09de9e4bb7861a96361ba79b833aa45f6833b15"
-        }, 
+        "ResponseMetadata": {},
         "Buckets": [
             {
+                "Name": "c7n-lifecycle-test-again3",
                 "CreationDate": {
-                    "hour": 19, 
-                    "__class__": "datetime", 
-                    "month": 10, 
-                    "second": 49, 
-                    "microsecond": 0, 
-                    "year": 2017, 
-                    "day": 27, 
-                    "minute": 53
-                }, 
-                "Name": "custodian-lifecycle-test"
-            }
-        ], 
-        "ResponseMetadata": {
-            "HTTPStatusCode": 200, 
-            "RetryAttempts": 0, 
-            "HostId": "/Niqb5BU2PcNxHA9QuRujdTTNwUAlQpq6svjzEqAZ6wOAg68hsquHe0M1YEAWtlVfrCFzgitJRo=", 
-            "RequestId": "92EC2CEA0AF80AD5", 
-            "HTTPHeaders": {
-                "x-amz-id-2": "/Niqb5BU2PcNxHA9QuRujdTTNwUAlQpq6svjzEqAZ6wOAg68hsquHe0M1YEAWtlVfrCFzgitJRo=", 
-                "server": "AmazonS3", 
-                "transfer-encoding": "chunked", 
-                "x-amz-request-id": "92EC2CEA0AF80AD5", 
-                "date": "Fri, 27 Oct 2017 19:53:50 GMT", 
-                "content-type": "application/xml"
+                    "__class__": "datetime",
+                    "year": 2022,
+                    "month": 6,
+                    "day": 15,
+                    "hour": 2,
+                    "minute": 55,
+                    "second": 59,
+                    "microsecond": 0
+                }
             }
+        ],
+        "Owner": {
+            "DisplayName": "mandeep.bal",
+            "ID": "e7c8bb65a5fc49cf906715eae09de9e4bb7861a96361ba79b833aa45f6833b15"
         }
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_3.json b/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_3.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_3.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_3.json
@@ -1,38 +1,25 @@
 {
-    "status_code": 200, 
+    "status_code": 200,
     "data": {
-        "Owner": {
-            "DisplayName": "mandeep.bal", 
-            "ID": "e7c8bb65a5fc49cf906715eae09de9e4bb7861a96361ba79b833aa45f6833b15"
-        }, 
+        "ResponseMetadata": {},
         "Buckets": [
             {
+                "Name": "c7n-lifecycle-test-again3",
                 "CreationDate": {
-                    "hour": 19, 
-                    "__class__": "datetime", 
-                    "month": 10, 
-                    "second": 49, 
-                    "microsecond": 0, 
-                    "year": 2017, 
-                    "day": 27, 
-                    "minute": 53
-                }, 
-                "Name": "custodian-lifecycle-test"
-            }
-        ], 
-        "ResponseMetadata": {
-            "HTTPStatusCode": 200, 
-            "RetryAttempts": 0, 
-            "HostId": "MoPHpR59FgLZuJlnanktP3jgUsQOqat1wLdGwqXP5Q6020pQ6EpNLOYUpbs4gTt2fInnPXVZwoQ=", 
-            "RequestId": "B17BEEC428D28092", 
-            "HTTPHeaders": {
-                "x-amz-id-2": "MoPHpR59FgLZuJlnanktP3jgUsQOqat1wLdGwqXP5Q6020pQ6EpNLOYUpbs4gTt2fInnPXVZwoQ=", 
-                "server": "AmazonS3", 
-                "transfer-encoding": "chunked", 
-                "x-amz-request-id": "B17BEEC428D28092", 
-                "date": "Fri, 27 Oct 2017 19:53:59 GMT", 
-                "content-type": "application/xml"
+                    "__class__": "datetime",
+                    "year": 2022,
+                    "month": 6,
+                    "day": 15,
+                    "hour": 2,
+                    "minute": 55,
+                    "second": 59,
+                    "microsecond": 0
+                }
             }
+        ],
+        "Owner": {
+            "DisplayName": "mandeep.bal",
+            "ID": "e7c8bb65a5fc49cf906715eae09de9e4bb7861a96361ba79b833aa45f6833b15"
         }
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_4.json b/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_4.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_4.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_4.json
@@ -1,38 +1,25 @@
 {
-    "status_code": 200, 
+    "status_code": 200,
     "data": {
-        "Owner": {
-            "DisplayName": "mandeep.bal", 
-            "ID": "e7c8bb65a5fc49cf906715eae09de9e4bb7861a96361ba79b833aa45f6833b15"
-        }, 
+        "ResponseMetadata": {},
         "Buckets": [
             {
+                "Name": "c7n-lifecycle-test-again3",
                 "CreationDate": {
-                    "hour": 19, 
-                    "__class__": "datetime", 
-                    "month": 10, 
-                    "second": 49, 
-                    "microsecond": 0, 
-                    "year": 2017, 
-                    "day": 27, 
-                    "minute": 53
-                }, 
-                "Name": "custodian-lifecycle-test"
-            }
-        ], 
-        "ResponseMetadata": {
-            "HTTPStatusCode": 200, 
-            "RetryAttempts": 0, 
-            "HostId": "Zl1UMp38xR9rfDDG3Tq448tJEKutlxOJ35XYDiBBYeB7oagF4ctcmQirjBNioXfOpBIPro1To3g=", 
-            "RequestId": "07E3575FD778025F", 
-            "HTTPHeaders": {
-                "x-amz-id-2": "Zl1UMp38xR9rfDDG3Tq448tJEKutlxOJ35XYDiBBYeB7oagF4ctcmQirjBNioXfOpBIPro1To3g=", 
-                "server": "AmazonS3", 
-                "transfer-encoding": "chunked", 
-                "x-amz-request-id": "07E3575FD778025F", 
-                "date": "Fri, 27 Oct 2017 19:54:09 GMT", 
-                "content-type": "application/xml"
+                    "__class__": "datetime",
+                    "year": 2022,
+                    "month": 6,
+                    "day": 15,
+                    "hour": 2,
+                    "minute": 55,
+                    "second": 59,
+                    "microsecond": 0
+                }
             }
+        ],
+        "Owner": {
+            "DisplayName": "mandeep.bal",
+            "ID": "e7c8bb65a5fc49cf906715eae09de9e4bb7861a96361ba79b833aa45f6833b15"
         }
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_5.json b/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_5.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_5.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.ListBuckets_5.json
@@ -1,38 +1,25 @@
 {
-    "status_code": 200, 
+    "status_code": 200,
     "data": {
-        "Owner": {
-            "DisplayName": "mandeep.bal", 
-            "ID": "e7c8bb65a5fc49cf906715eae09de9e4bb7861a96361ba79b833aa45f6833b15"
-        }, 
+        "ResponseMetadata": {},
         "Buckets": [
             {
+                "Name": "c7n-lifecycle-test-again3",
                 "CreationDate": {
-                    "hour": 19, 
-                    "__class__": "datetime", 
-                    "month": 10, 
-                    "second": 49, 
-                    "microsecond": 0, 
-                    "year": 2017, 
-                    "day": 27, 
-                    "minute": 53
-                }, 
-                "Name": "custodian-lifecycle-test"
-            } 
-        ], 
-        "ResponseMetadata": {
-            "HTTPStatusCode": 200, 
-            "RetryAttempts": 0, 
-            "HostId": "wwdayWqZoevTQ2kcrGHX7IJClYAx34Yc+lSo7xyut8k5f4+fVbY1TrNFH6uYj54xZNt+hEtIua8=", 
-            "RequestId": "90C7E3CEA708DC06", 
-            "HTTPHeaders": {
-                "x-amz-id-2": "wwdayWqZoevTQ2kcrGHX7IJClYAx34Yc+lSo7xyut8k5f4+fVbY1TrNFH6uYj54xZNt+hEtIua8=", 
-                "server": "AmazonS3", 
-                "transfer-encoding": "chunked", 
-                "x-amz-request-id": "90C7E3CEA708DC06", 
-                "date": "Fri, 27 Oct 2017 19:54:19 GMT", 
-                "content-type": "application/xml"
+                    "__class__": "datetime",
+                    "year": 2022,
+                    "month": 6,
+                    "day": 15,
+                    "hour": 2,
+                    "minute": 55,
+                    "second": 59,
+                    "microsecond": 0
+                }
             }
+        ],
+        "Owner": {
+            "DisplayName": "mandeep.bal",
+            "ID": "e7c8bb65a5fc49cf906715eae09de9e4bb7861a96361ba79b833aa45f6833b15"
         }
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.ListObjects_1.json b/tests/data/placebo/test_s3_lifecycle/s3.ListObjects_1.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.ListObjects_1.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.ListObjects_1.json
@@ -1,26 +1,12 @@
 {
-    "status_code": 200, 
+    "status_code": 200,
     "data": {
-        "MaxKeys": 1000, 
-        "Prefix": "", 
-        "Name": "custodian-lifecycle-test", 
-        "ResponseMetadata": {
-            "HTTPStatusCode": 200, 
-            "RetryAttempts": 0, 
-            "HostId": "YFsFZV1czPThuKvh9Tc0cBF60+HfSqqcxoHn0n7VZ4vE+GOZSim15AI8FpG7kDhgnXdulMuf44E=", 
-            "RequestId": "56A09287317F615C", 
-            "HTTPHeaders": {
-                "x-amz-bucket-region": "us-east-1", 
-                "x-amz-id-2": "YFsFZV1czPThuKvh9Tc0cBF60+HfSqqcxoHn0n7VZ4vE+GOZSim15AI8FpG7kDhgnXdulMuf44E=", 
-                "server": "AmazonS3", 
-                "transfer-encoding": "chunked", 
-                "x-amz-request-id": "56A09287317F615C", 
-                "date": "Fri, 27 Oct 2017 19:54:28 GMT", 
-                "content-type": "application/xml"
-            }
-        }, 
-        "Marker": "", 
-        "EncodingType": "url", 
-        "IsTruncated": false
+        "ResponseMetadata": {},
+        "IsTruncated": false,
+        "Marker": "",
+        "Name": "c7n-lifecycle-test-again3",
+        "Prefix": "",
+        "MaxKeys": 1000,
+        "EncodingType": "url"
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.PutBucketLifecycleConfiguration_1.json b/tests/data/placebo/test_s3_lifecycle/s3.PutBucketLifecycleConfiguration_1.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.PutBucketLifecycleConfiguration_1.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.PutBucketLifecycleConfiguration_1.json
@@ -1,18 +1,6 @@
 {
-    "status_code": 200, 
+    "status_code": 200,
     "data": {
-        "ResponseMetadata": {
-            "HTTPStatusCode": 200, 
-            "RetryAttempts": 0, 
-            "HostId": "9+xWg4DAg5BgdKqP8/X07YGtQ0TOhyF/2aIvIo5NUDRQvWcFBr7NSAHFOv1LJWKScOQljQO2OqA=", 
-            "RequestId": "6BC296CE54946DF6", 
-            "HTTPHeaders": {
-                "x-amz-id-2": "9+xWg4DAg5BgdKqP8/X07YGtQ0TOhyF/2aIvIo5NUDRQvWcFBr7NSAHFOv1LJWKScOQljQO2OqA=", 
-                "date": "Fri, 27 Oct 2017 19:53:53 GMT", 
-                "content-length": "0", 
-                "x-amz-request-id": "6BC296CE54946DF6", 
-                "server": "AmazonS3"
-            }
-        }
+        "ResponseMetadata": {}
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.PutBucketLifecycleConfiguration_2.json b/tests/data/placebo/test_s3_lifecycle/s3.PutBucketLifecycleConfiguration_2.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.PutBucketLifecycleConfiguration_2.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.PutBucketLifecycleConfiguration_2.json
@@ -1,18 +1,6 @@
 {
-    "status_code": 200, 
+    "status_code": 200,
     "data": {
-        "ResponseMetadata": {
-            "HTTPStatusCode": 200, 
-            "RetryAttempts": 0, 
-            "HostId": "s888TPM6roMKqgkgQAwDruzmom4BOMF0kjsLxn5cbOxn4v9wNwPkP4BHyZvMb41J2CU7bvs6kw4=", 
-            "RequestId": "806487E1892E4C8A", 
-            "HTTPHeaders": {
-                "x-amz-id-2": "s888TPM6roMKqgkgQAwDruzmom4BOMF0kjsLxn5cbOxn4v9wNwPkP4BHyZvMb41J2CU7bvs6kw4=", 
-                "date": "Fri, 27 Oct 2017 19:54:03 GMT", 
-                "content-length": "0", 
-                "x-amz-request-id": "806487E1892E4C8A", 
-                "server": "AmazonS3"
-            }
-        }
+        "ResponseMetadata": {}
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.PutBucketLifecycleConfiguration_3.json b/tests/data/placebo/test_s3_lifecycle/s3.PutBucketLifecycleConfiguration_3.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.PutBucketLifecycleConfiguration_3.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.PutBucketLifecycleConfiguration_3.json
@@ -1,18 +1,6 @@
 {
-    "status_code": 200, 
+    "status_code": 200,
     "data": {
-        "ResponseMetadata": {
-            "HTTPStatusCode": 200, 
-            "RetryAttempts": 0, 
-            "HostId": "SIiiqk81N7WmwaA2uNHr2rqBA3sP+LeRtUkIZb4Ierw3HGGIFTfct4NKUNxO/CmbdiVMdByOFsQ=", 
-            "RequestId": "45F0AD21671B5EFE", 
-            "HTTPHeaders": {
-                "x-amz-id-2": "SIiiqk81N7WmwaA2uNHr2rqBA3sP+LeRtUkIZb4Ierw3HGGIFTfct4NKUNxO/CmbdiVMdByOFsQ=", 
-                "date": "Fri, 27 Oct 2017 19:54:13 GMT", 
-                "content-length": "0", 
-                "x-amz-request-id": "45F0AD21671B5EFE", 
-                "server": "AmazonS3"
-            }
-        }
+        "ResponseMetadata": {}
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_lifecycle/s3.PutBucketLifecycleConfiguration_4.json b/tests/data/placebo/test_s3_lifecycle/s3.PutBucketLifecycleConfiguration_4.json
--- a/tests/data/placebo/test_s3_lifecycle/s3.PutBucketLifecycleConfiguration_4.json
+++ b/tests/data/placebo/test_s3_lifecycle/s3.PutBucketLifecycleConfiguration_4.json
@@ -1,18 +1,6 @@
 {
-    "status_code": 200, 
+    "status_code": 200,
     "data": {
-        "ResponseMetadata": {
-            "HTTPStatusCode": 200, 
-            "RetryAttempts": 0, 
-            "HostId": "ELu5d7TyrF5hO/9xosk1z/4VwQsvAOUB2wIJQl+2CIzAakOE/EVSCuIN2kXlQcgEhbQ4hS4JOQo=", 
-            "RequestId": "1A9317A6244F4B3D", 
-            "HTTPHeaders": {
-                "x-amz-id-2": "ELu5d7TyrF5hO/9xosk1z/4VwQsvAOUB2wIJQl+2CIzAakOE/EVSCuIN2kXlQcgEhbQ4hS4JOQo=", 
-                "date": "Fri, 27 Oct 2017 19:54:22 GMT", 
-                "content-length": "0", 
-                "x-amz-request-id": "1A9317A6244F4B3D", 
-                "server": "AmazonS3"
-            }
-        }
+        "ResponseMetadata": {}
     }
 }
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_remove_lifecycle_rule_id/s3.DeleteBucketLifecycle_1.json b/tests/data/placebo/test_s3_remove_lifecycle_rule_id/s3.DeleteBucketLifecycle_1.json
new file mode 100644
--- /dev/null
+++ b/tests/data/placebo/test_s3_remove_lifecycle_rule_id/s3.DeleteBucketLifecycle_1.json
@@ -0,0 +1,6 @@
+{
+    "status_code": 204,
+    "data": {
+        "ResponseMetadata": {}
+    }
+}
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_remove_lifecycle_rule_id/s3.GetBucketLifecycleConfiguration_1.json b/tests/data/placebo/test_s3_remove_lifecycle_rule_id/s3.GetBucketLifecycleConfiguration_1.json
new file mode 100644
--- /dev/null
+++ b/tests/data/placebo/test_s3_remove_lifecycle_rule_id/s3.GetBucketLifecycleConfiguration_1.json
@@ -0,0 +1,30 @@
+{
+    "status_code": 200,
+    "data": {
+        "ResponseMetadata": {},
+        "Rules": [
+            {
+                "Expiration": {
+                    "Date": {
+                        "__class__": "datetime",
+                        "year": 2022,
+                        "month": 3,
+                        "day": 4,
+                        "hour": 0,
+                        "minute": 0,
+                        "second": 0,
+                        "microsecond": 0
+                    }
+                },
+                "ID": "id2",
+                "Filter": {
+                    "Tag": {
+                        "Key": "dataSetRegistered",
+                        "Value": "2022-12-03"
+                    }
+                },
+                "Status": "Enabled"
+            }
+        ]
+    }
+}
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_remove_lifecycle_rule_id/s3.GetBucketLifecycleConfiguration_2.json b/tests/data/placebo/test_s3_remove_lifecycle_rule_id/s3.GetBucketLifecycleConfiguration_2.json
new file mode 100644
--- /dev/null
+++ b/tests/data/placebo/test_s3_remove_lifecycle_rule_id/s3.GetBucketLifecycleConfiguration_2.json
@@ -0,0 +1,30 @@
+{
+    "status_code": 200,
+    "data": {
+        "ResponseMetadata": {},
+        "Rules": [
+            {
+                "Expiration": {
+                    "Date": {
+                        "__class__": "datetime",
+                        "year": 2022,
+                        "month": 3,
+                        "day": 4,
+                        "hour": 0,
+                        "minute": 0,
+                        "second": 0,
+                        "microsecond": 0
+                    }
+                },
+                "ID": "id2",
+                "Filter": {
+                    "Tag": {
+                        "Key": "dataSetRegistered",
+                        "Value": "2022-12-03"
+                    }
+                },
+                "Status": "Enabled"
+            }
+        ]
+    }
+}
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_remove_lifecycle_rule_id/s3.GetBucketLifecycleConfiguration_3.json b/tests/data/placebo/test_s3_remove_lifecycle_rule_id/s3.GetBucketLifecycleConfiguration_3.json
new file mode 100644
--- /dev/null
+++ b/tests/data/placebo/test_s3_remove_lifecycle_rule_id/s3.GetBucketLifecycleConfiguration_3.json
@@ -0,0 +1,11 @@
+{
+    "status_code": 404,
+    "data": {
+        "Error": {
+            "Code": "NoSuchLifecycleConfiguration",
+            "Message": "The lifecycle configuration does not exist",
+            "BucketName": "c7n-test-1"
+        },
+        "ResponseMetadata": {}
+    }
+}
\ No newline at end of file
diff --git a/tests/data/placebo/test_s3_remove_lifecycle_rule_id/s3.ListBuckets_1.json b/tests/data/placebo/test_s3_remove_lifecycle_rule_id/s3.ListBuckets_1.json
new file mode 100644
--- /dev/null
+++ b/tests/data/placebo/test_s3_remove_lifecycle_rule_id/s3.ListBuckets_1.json
@@ -0,0 +1,25 @@
+{
+    "status_code": 200,
+    "data": {
+        "ResponseMetadata": {},
+        "Buckets": [
+            {
+                "Name": "c7n-test-1",
+                "CreationDate": {
+                    "__class__": "datetime",
+                    "year": 2021,
+                    "month": 2,
+                    "day": 2,
+                    "hour": 4,
+                    "minute": 47,
+                    "second": 57,
+                    "microsecond": 0
+                }
+            }
+        ],
+        "Owner": {
+            "DisplayName": "mandeep.bal",
+            "ID": "e7c8bb65a5fc49cf906715eae09de9e4bb7861a96361ba79b833aa45f6833b15"
+        }
+    }
+}
\ No newline at end of file
diff --git a/tests/test_s3.py b/tests/test_s3.py
--- a/tests/test_s3.py
+++ b/tests/test_s3.py
@@ -3625,7 +3625,7 @@ def test_lifecycle(self):
         session_factory = self.replay_flight_data("test_s3_lifecycle")
         session = session_factory()
         client = session.client("s3")
-        bname = "custodian-lifecycle-test"
+        bname = "c7n-lifecycle-test-again3"
 
         # Make a bucket
         client.create_bucket(Bucket=bname)
@@ -3636,7 +3636,7 @@ def test_lifecycle(self):
         def get_policy(**kwargs):
             rule = {
                 "Status": "Enabled",
-                "Prefix": "foo/",
+                "Filter": {"Prefix": "foo/"},
                 "Transitions": [{"Days": 60, "StorageClass": "GLACIER"}],
             }
             rule.update(**kwargs)
@@ -3670,7 +3670,7 @@ def run_policy(policy):
         # Now add another lifecycle rule to ensure it doesn't clobber the first one
         #
         lifecycle_id2 = "test-lifecycle-two"
-        policy = get_policy(ID=lifecycle_id2, Prefix="bar/")
+        policy = get_policy(ID=lifecycle_id2, Filter={"Prefix": "bar/"})
         run_policy(policy)
 
         # Verify the lifecycle
@@ -3684,7 +3684,7 @@ def run_policy(policy):
         #
         # Next, overwrite one of the lifecycles and make sure it changed
         #
-        policy = get_policy(ID=lifecycle_id2, Prefix="baz/")
+        policy = get_policy(ID=lifecycle_id2, Filter={"Prefix": "baz/"})
         run_policy(policy)
 
         # Verify the lifecycle
@@ -3697,7 +3697,7 @@ def run_policy(policy):
 
         for rule in lifecycle["Rules"]:
             if rule["ID"] == lifecycle_id2:
-                self.assertEqual(rule["Prefix"], "baz/")
+                self.assertEqual(rule["Filter"]["Prefix"], "baz/")
 
         #
         # Test deleting a lifecycle
@@ -3709,6 +3709,52 @@ def run_policy(policy):
         self.assertEqual(len(lifecycle["Rules"]), 1)
         self.assertEqual(lifecycle["Rules"][0]["ID"], lifecycle_id2)
 
+    def test_s3_remove_lifecycle_rule_id(self):
+        self.patch(s3.S3, "executor_factory", MainThreadExecutor)
+        self.patch(
+            s3,
+            "S3_AUGMENT_TABLE",
+            [("get_bucket_lifecycle_configuration", "Lifecycle", None, None)],)
+        bname = 'c7n-test-1'
+        session_factory = self.replay_flight_data("test_s3_remove_lifecycle_rule_id")
+        session = session_factory()
+        client = session.client("s3")
+        lifecycle = client.get_bucket_lifecycle_configuration(Bucket=bname)
+        self.assertSetEqual(
+            {x["ID"] for x in lifecycle["Rules"]},
+            {'id2'},)
+        p = self.load_policy(
+            {
+                "name": "s3-remove-lc-rule-id",
+                "resource": "s3",
+                "filters": [
+                    {
+                        "Name": bname
+                    }
+                ],
+                "actions": [
+                    {
+                        "type": "configure-lifecycle",
+                        "rules": [
+                            {
+                                "ID": "id2",
+                                "Status": "absent",
+                            },
+                            {
+                                "ID": "id1",
+                                "Status": "absent",
+                            },
+                        ]
+                    }
+                ],
+            },
+            session_factory=session_factory,
+        )
+        resources = p.run()
+        self.assertEqual(len(resources), 1)
+        with self.assertRaises(Exception):
+            client.get_bucket_lifecycle_configuration(Bucket=bname)
+
 
 @terraform('aws_s3_encryption_audit')
 def test_s3_encryption_audit(test, aws_s3_encryption_audit):