Repository: localstack/localstack

Issue:
bug: s3.PutBucketLogging fails with 500 when deleting bucket
### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

Given the following minimal terraform code that creates two s3 buckets where one of the buckets is used for logging

```tf
terraform {
  required_version = ">= 1.5.2"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.8.0"
    }
  }
}

resource "aws_s3_bucket" "bucket" {
  bucket = "main"
}

resource "aws_s3_bucket" "logging" {
  bucket = "logging"
}

resource "aws_s3_bucket_logging" "bucket" {
  bucket = aws_s3_bucket.bucket.id

  target_bucket = aws_s3_bucket.logging.id
  target_prefix = "log/"
}
```

Using `tflocal` to `tflocal apply` the resources to localstack running in docker-compose works as expected but `tflocal destroy` will become stuck at 
```
aws_s3_bucket_logging.bucket: Destroying... [id=main]
aws_s3_bucket_logging.bucket: Still destroying... [id=main, 10s elapsed]
```

when reviewing the localstack output the following error is observed repeatedly

```
localstack_main | 2023-08-03T00:01:55.897  INFO --- [   asgi_gw_2] localstack.request.aws     : AWS s3.PutBucketLogging => 500 (InternalError)
localstack_main | 2023-08-03T00:01:55.899  INFO --- [   asgi_gw_1] localstack.request.http    : PUT / => 500
localstack_main | 2023-08-03T00:01:55.949 ERROR --- [   asgi_gw_2] l.aws.handlers.logging     : exception during call chain: 'NoneType' object has no attribute 'get'
```

### Expected Behavior

`tflocal destroy` to destroy the `aws_s3_bucket_logging` logging resource.  Using terraform instead of tflocal with the same terraform configuration succeeds during apply and destroy

### How are you starting LocalStack?

With a docker-compose file

### Steps To Reproduce

1. Create a minimal terraform module with a `main.tf` that includes the terraform code above
2. from the terraform module execute `tflocal init`
3. from the terraform module execute `tflocal apply`
4. observe the resources are created in localstack
5. from the terraform module execute `tflocal destroy`
6. observe the 500 error in the localstack logs and the terraform output is stuck on "Still destroying..."


### Environment

```markdown
- OS: macOS 13.4.1
- LocalStack: latest
```


### Anything else?

_No response_


Discussion:
Welcome to LocalStack! Thanks for reporting your first issue and our team will be working towards fixing the issue for you or reach out for more background information. We recommend joining our [Slack Community](https://localstack.cloud/contact/) for real-time help and drop a message to LocalStack Pro Support if you are a Pro user! If you are willing to contribute towards fixing this issue, please have a look at our [contributing guidelines](https://github.com/localstack/.github/blob/main/CONTRIBUTING.md) and our [contributing guide](https://docs.localstack.cloud/contributing/).

Resolving patch:
diff --git a/localstack/services/s3/provider.py b/localstack/services/s3/provider.py
--- a/localstack/services/s3/provider.py
+++ b/localstack/services/s3/provider.py
@@ -1634,6 +1634,7 @@ def put_bucket_logging(
 
         if not (logging_config := bucket_logging_status.get("LoggingEnabled")):
             moto_bucket.logging = {}
+            return
 
         # the target bucket must be in the same account
         if not (target_bucket_name := logging_config.get("TargetBucket")):


Test patch:
diff --git a/tests/integration/s3/test_s3.py b/tests/integration/s3/test_s3.py
--- a/tests/integration/s3/test_s3.py
+++ b/tests/integration/s3/test_s3.py
@@ -5062,6 +5062,10 @@ def test_put_bucket_logging(self, aws_client, s3_create_bucket, snapshot):
         resp = aws_client.s3.get_bucket_logging(Bucket=bucket_name)
         snapshot.match("get-bucket-logging", resp)
 
+        # delete BucketLogging
+        resp = aws_client.s3.put_bucket_logging(Bucket=bucket_name, BucketLoggingStatus={})
+        snapshot.match("put-bucket-logging-delete", resp)
+
     @markers.parity.aws_validated
     def test_put_bucket_logging_accept_wrong_grants(self, aws_client, s3_create_bucket, snapshot):
         snapshot.add_transformer(snapshot.transform.key_value("TargetBucket"))
diff --git a/tests/integration/s3/test_s3.snapshot.json b/tests/integration/s3/test_s3.snapshot.json
--- a/tests/integration/s3/test_s3.snapshot.json
+++ b/tests/integration/s3/test_s3.snapshot.json
@@ -7750,7 +7750,7 @@
     }
   },
   "tests/integration/s3/test_s3.py::TestS3::test_put_bucket_logging": {
-    "recorded-date": "08-07-2023, 02:00:56",
+    "recorded-date": "03-08-2023, 02:13:19",
     "recorded-content": {
       "get-bucket-default-acl": {
         "Grants": [
@@ -7787,6 +7787,12 @@
           "HTTPHeaders": {},
           "HTTPStatusCode": 200
         }
+      },
+      "put-bucket-logging-delete": {
+        "ResponseMetadata": {
+          "HTTPHeaders": {},
+          "HTTPStatusCode": 200
+        }
       }
     }
   },