Skip to content

Commit

Permalink
fix(bucket): Reset notification configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Blatt (external expert on behalf of DB Netz) <[email protected]>
  • Loading branch information
MisterMX committed Dec 13, 2023
1 parent 4124fb7 commit c032dcc
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 c032dcc

Please sign in to comment.