# LifecycleConfiguration with expiration rule does not work with a prefix filter

**URL:** <https://community.fly.io/t/lifecycleconfiguration-with-expiration-rule-does-not-work-with-a-prefix-filter/22118>\
**Category:** General\
**Tags:** storage, tigris, dotnet, login-only\
**Created:** [October 3, 2024, 8:23am UTC](https://community.fly.io/t/lifecycleconfiguration-with-expiration-rule-does-not-work-with-a-prefix-filter/22118 "2024-10-03T08:23:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![goncalo-oliveira](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/goncalo-oliveira/32/13429_2.png) [@goncalo-oliveira](https://community.fly.io/u/goncalo-oliveira)\
**Post date:** [October 3, 2024, 8:23am UTC](https://community.fly.io/t/lifecycleconfiguration-with-expiration-rule-does-not-work-with-a-prefix-filter/22118/1 "2024-10-03T08:23:17Z")

</div>

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

```auto
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

```csharp
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 );

```

---

<div class="post-metadata">

**Author:** ![goncalo-oliveira](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/goncalo-oliveira/32/13429_2.png) [@goncalo-oliveira](https://community.fly.io/u/goncalo-oliveira)\
**Post date:** [October 3, 2024, 8:37am UTC](https://community.fly.io/t/lifecycleconfiguration-with-expiration-rule-does-not-work-with-a-prefix-filter/22118/2 "2024-10-03T08:37:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mayailurus](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/mayailurus/32/17593_2.png) [@mayailurus](https://community.fly.io/u/mayailurus)\
**Post date:** [October 3, 2024, 4:36pm UTC](https://community.fly.io/t/lifecycleconfiguration-with-expiration-rule-does-not-work-with-a-prefix-filter/22118/3 "2024-10-03T16:36:43Z")

</div>

Added #dotnet, #tigris

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/fly1/original/3X/6/e/6e8955d00cb218e186ebbe3a6ab06fefdce15290.svg) [@system](https://community.fly.io/u/system)\
**Post date:** [October 10, 2024, 4:36pm UTC](https://community.fly.io/t/lifecycleconfiguration-with-expiration-rule-does-not-work-with-a-prefix-filter/22118/4 "2024-10-10T16:36:55Z")

</div>

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