Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Use DeleteBucketLifecycle
with an Amazon SDK or CLI
The following code examples show how to use DeleteBucketLifecycle
.
- .NET
-
- Amazon SDK for .NET
-
/// <summary>
/// This method removes the Lifecycle configuration from the named
/// S3 bucket.
/// </summary>
/// <param name="client">The S3 client object used to call
/// the RemoveLifecycleConfigAsync method.</param>
/// <param name="bucketName">A string representing the name of the
/// S3 bucket from which the configuration will be removed.</param>
public static async Task RemoveLifecycleConfigAsync(IAmazonS3 client, string bucketName)
{
var request = new DeleteLifecycleConfigurationRequest()
{
BucketName = bucketName,
};
await client.DeleteLifecycleConfigurationAsync(request);
}
- CLI
-
- Amazon CLI
-
The following command deletes a lifecycle configuration from a bucket named amzn-s3-demo-bucket
:
aws s3api delete-bucket-lifecycle --bucket amzn-s3-demo-bucket
- Python
-
- SDK for Python (Boto3)
-
class BucketWrapper:
"""Encapsulates S3 bucket actions."""
def __init__(self, bucket):
"""
:param bucket: A Boto3 Bucket resource. This is a high-level resource in Boto3
that wraps bucket actions in a class-like structure.
"""
self.bucket = bucket
self.name = bucket.name
def delete_lifecycle_configuration(self):
"""
Remove the lifecycle configuration from the specified bucket.
"""
try:
self.bucket.LifecycleConfiguration().delete()
logger.info(
"Deleted lifecycle configuration for bucket '%s'.", self.bucket.name
)
except ClientError:
logger.exception(
"Couldn't delete lifecycle configuration for bucket '%s'.",
self.bucket.name,
)
raise
For a complete list of Amazon SDK developer guides and code examples, see
Developing with Amazon S3 using the Amazon SDKs.
This topic also includes information about getting started and details about previous SDK versions.