You can use the boto3 library in Python to list the S3 buckets in an AWS account and identify which buckets have lifecycle management enabled. Here's a Python program to achieve this, along with clear output detailing the status of each bucket's lifecycle configuration:
```
import boto3
def list_buckets_with_lifecycle_enabled():
s3 = boto3.client('s3')
# List all S3 buckets
response = s3.list_buckets()
for bucket in response['Buckets']:
bucket_name = bucket['Name']
print(f"Bucket Name: {bucket_name}")
# Check if the bucket has a lifecycle configuration
try:
lifecycle_config = s3.get_bucket_lifecycle_configuration(Bucket=bucket_name)
print("Lifecycle Management: Enabled")
print("Lifecycle Configuration:")
print(lifecycle_config)
except s3.exceptions.NoSuchLifecycleConfiguration:
print("Lifecycle Management: Disabled")
print("\n")
if __name__ == "__main__":
list_buckets_with_lifecycle_enabled()
```
Make sure you have the boto3 library installed and configured with your AWS credentials. This script lists all S3 buckets in your AWS account and checks if each bucket has a lifecycle configuration. If a bucket has lifecycle management enabled, it prints the configuration details; otherwise, it indicates that lifecycle management is disabled.
Simply run the script, and it will provide clear output showing the status of each bucket's lifecycle configuration.