From 49e0188a752dbe60235cc5b4960b9787f9ee74ab Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Fri, 10 Jun 2022 16:25:15 +0200 Subject: [PATCH] only configure lifecycle policy if at least one expiration class has been configured --- pkg/server/setup.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/server/setup.go b/pkg/server/setup.go index f28d5e7..ef01e3c 100644 --- a/pkg/server/setup.go +++ b/pkg/server/setup.go @@ -79,13 +79,15 @@ func (s *Server) Setup() error { }) } - if _, err := s.PutBucketLifecycleConfiguration(&s3.PutBucketLifecycleConfigurationInput{ - Bucket: aws.String(s.Config.Bucket), - LifecycleConfiguration: &s3.BucketLifecycleConfiguration{ - Rules: lcRules, - }, - }); err != nil { - return fmt.Errorf("failed to set bucket %s's lifecycle rules: %w", s.Config.Bucket, err) + if len(lcRules) > 0 { + if _, err := s.PutBucketLifecycleConfiguration(&s3.PutBucketLifecycleConfigurationInput{ + Bucket: aws.String(s.Config.Bucket), + LifecycleConfiguration: &s3.BucketLifecycleConfiguration{ + Rules: lcRules, + }, + }); err != nil { + return fmt.Errorf("failed to set bucket %s's lifecycle rules: %w", s.Config.Bucket, err) + } } // lc, err := svc.GetBucketLifecycleConfiguration(&s3.GetBucketLifecycleConfigurationInput{