I want to apply S3 LifecycleConfiguration from .net SDK for below criteria
- Prefix, e.g. "tempdocs/"
- Tag with its value, e.g { "OneDayExpiry" : "true" }
I'm referring this documentation : https://docs.aws.amazon.com/AmazonS3/latest/userguide/how-to-set-lifecycle-configuration-intro.html
I can't find option for applying tag by LifecycleTagPredicate
, which can consider Tag for LifeCycleRule to delete S3 files
Here is sample rule, where I can only apply expiry days and prefix, but can't find property for Tags
var lifeCycleConfiguration = new LifecycleConfiguration()
{
Rules = new List<LifecycleRule>
{
new LifecycleRule
{
Id = "Delete one day old objects",
Filter = new LifecycleFilter()
{
LifecycleFilterPredicate = new LifecyclePrefixPredicate()
{
Prefix = "tempdocs/"
}
},
Status = LifecycleRuleStatus.Enabled,
Expiration = new LifecycleRuleExpiration()
{
Days = 1
}
}
}
};
I can see tag property as LifecycleTagPredicate
in Java and node SDK as below, but can't find this in .Net SDK
JAVA SDK
BucketLifecycleConfiguration.Rule rule2 = new BucketLifecycleConfiguration.Rule()
.withId("Archive and then delete rule")
.withFilter(new LifecycleFilter(new LifecycleTagPredicate(new Tag("archive", "true"))))
.addTransition(new Transition().withDays(30).withStorageClass(StorageClass.StandardInfrequentAccess))
.addTransition(new Transition().withDays(365).withStorageClass(StorageClass.Glacier))
.withExpirationInDays(3650)
.withStatus(BucketLifecycleConfiguration.ENABLED);
Do we have any way to create Rule for specific tag in .Net Core SDK?
AWS documentation for .net https://docs.aws.amazon.com/AmazonS3/latest/userguide/how-to-set-lifecycle-configuration-intro.html does not have updated example for LifeCycle rule, and certain properties are deprecated.
After looking at AWS SDK code for .net and referring to @rlhagerm's answer, Found that as part of Visitor pattern implementation of
LifeCycleRule
,LifecycleFilterPredicate
can take multiple values likePrefix
andTag
, where both will be part of sameOperands
for given Ruleby this we can create single rule which can suffice both
Prefix
andTag
to create policy to auto delete files.