LifecycleConfiguration with expiration rule does not work with a prefix filter

Trying to set an expiration rule with PutLifecycleConfiguration. I am using .NET and AWS SDK for that. I do a GetLifecycleConfiguration first, to ensure I’m not deleting any existing policies and append an expiration rule with N days.

This works perfectly well with other S3 APIs, but with Tigris I am getting an exception

Lifecycle only supports expiration rule. Expiration rule with content days or dates only.

It’s a bit awkward, because it’s exactly what I am trying to do, set an expiration rule with days. Here’s the gist of the code

var lifecycleConfigurationResponse = await s3Client.GetLifecycleConfigurationAsync( bucketName, cancellationToken );

var lifecycleConfigurationRules = lifecycleConfigurationResponse.Configuration.Rules.Except(
    lifecycleConfigurationResponse.Configuration.Rules.Where( r => r.Id == "messages-retention-policy" )
)
.Append(
    new LifecycleRule
    {
        Id = "messages-retention-policy",
        Filter = new()
        {
            LifecycleFilterPredicate = new LifecyclePrefixPredicate
            {
                Prefix = "messages/"
            }
        },
        Status = LifecycleRuleStatus.Enabled,
        Expiration = new LifecycleRuleExpiration
        {
            Days = Math.Max( 1, (int)options.RetentionPeriod.TotalDays )
        }
    }
)
.ToList();

var putLifecycleRequest = new PutLifecycleConfigurationRequest
{
    BucketName = bucketName,
    Configuration = new LifecycleConfiguration
    {
        Rules = lifecycleConfigurationRules
    }
};

var putLifecycleResponse = await s3Client.PutLifecycleConfigurationAsync( putLifecycleRequest, cancellationToken );

Alright, after digging into the console and seeing that a global TTL exists, I’ve tried doing the request without the prefix filter and this does work.

So… it’s possible to set an expiration rule, as long as there is no filter. This matches what is offered in the console.

To me this is a no-go. Not all objects have the same importance, so I do think that it should be allowed to set an expiration rule with a filter.

Added dotnet, tigris

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.