Skip to content

Commit

Permalink
only configure lifecycle policy if at least one expiration class has …
Browse files Browse the repository at this point in the history
…been configured
  • Loading branch information
stv0g committed Jun 10, 2022
1 parent 02ac7f9 commit 49e0188
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pkg/server/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 49e0188

Please sign in to comment.