Skip to content

Commit

Permalink
Merge pull request crossplane-contrib#1974 from MisterMX/fix/bucket-n…
Browse files Browse the repository at this point in the history
…otification-config-delete

fix(bucket): Reset notification configuration
  • Loading branch information
MisterMX authored Dec 18, 2023
2 parents 0009150 + c032dcc commit 4ecbd4c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/controller/s3/bucket/notificationConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/crossplane/crossplane-runtime/pkg/meta"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"k8s.io/utils/ptr"

"github.com/crossplane-contrib/provider-aws/apis/s3/v1beta1"
"github.com/crossplane-contrib/provider-aws/pkg/clients/s3"
Expand Down Expand Up @@ -285,9 +286,18 @@ func (in *NotificationConfigurationClient) CreateOrUpdate(ctx context.Context, b
return errorutils.Wrap(err, notificationPutFailed)
}

// Delete does nothing because there is no corresponding deletion call in awsclient.
func (*NotificationConfigurationClient) Delete(_ context.Context, _ *v1beta1.Bucket) error {
return nil
// Delete resets the buckets notification configuration to empty.
func (in *NotificationConfigurationClient) Delete(ctx context.Context, bucket *v1beta1.Bucket) error {
_, err := in.client.PutBucketNotificationConfiguration(ctx, &awss3.PutBucketNotificationConfigurationInput{
Bucket: ptr.To(meta.GetExternalName(bucket)),
NotificationConfiguration: &types.NotificationConfiguration{
EventBridgeConfiguration: &types.EventBridgeConfiguration{},
LambdaFunctionConfigurations: []types.LambdaFunctionConfiguration{},
QueueConfigurations: []types.QueueConfiguration{},
TopicConfigurations: []types.TopicConfiguration{},
},
})
return errorutils.Wrap(err, notificationPutFailed)
}

// LateInitialize is responsible for initializing the resource based on the external value
Expand Down

0 comments on commit 4ecbd4c

Please sign in to comment.