- Newest
- Most votes
- Most comments
Hi there!
You cannot add the ExpiredObjectDeleteMarker configuration within the same expiration rule where you specify a Days or Date value.
Try having two separate rules for the LifeCycleConfiguration. Something like this:
response = bucket_lifecycle_configuration.put(
LifecycleConfiguration={
'Rules': [
{
'Expiration': {
'Days': 1
},
'ID': 'Rule01',
'Status': 'Enabled',
'Filter': {'Prefix': ''},
'NoncurrentVersionExpiration': {
'NoncurrentDays': 1
},
'AbortIncompleteMultipartUpload': {
'DaysAfterInitiation': 1
}
},
{
'Expiration': {
'ExpiredObjectDeleteMarker': True
},
'ID': 'Rule02',
'Status': 'Enabled',
'Filter': {'Prefix': ''}
}
]
}
)
The documentation for S3.BucketLifecycleConfiguration.put()
states:
ExpiredObjectDeleteMarker (boolean) --
Indicates whether Amazon S3 will remove a delete marker with no noncurrent versions. If set to true, the delete marker will be expired; if set to false the policy takes no action. This cannot be specified with Days or Date in a Lifecycle Expiration Policy.
-- https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.BucketLifecycleConfiguration.put (emphasis mine)
Specifying 'Expiration': { 'Days': 1 }
causes current versions to expire after one day.
The 'NoncurrentVersionExpiration': { 'NoncurrentDays': 1 }
block specifies that non-current versions are deleted one day after Expiration.
Hi thanks for the reply
Yes sure this is the code I wrote. The question is about the expired object delete marker)))
I have read the doc before writing the code.
With the AWS console I can set up the lifecycle rule for expired object delete markers but not on code...
When some buckets can't be delete with the console, the only solution is to put a lifecycle rule for deleting
- current versions
- non current versions
- expired object delete markers
according to AWS documentation...
So the issue remains
Thanks for the help
Relevant content
- asked 3 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
Hi ))) Yes I should have thought about that. This is the solution Thanks Fabio