AWS资源具有公共的属性,并且可以使用AWS SDK来访问它们。以下是一个使用Python Boto3 SDK的示例代码,用于获取S3存储桶列表,并打印它们的公共属性:
import boto3
s3 = boto3.client('s3')
buckets = s3.list_buckets()
for bucket in buckets['Buckets']:
print("Bucket Name: {}".format(bucket['Name']))
print("Creation Date: {}".format(bucket['CreationDate']))
print("Owner: {}".format(bucket['Owner']['DisplayName']))
print("Location: {}".format(s3.get_bucket_location(Bucket=bucket['Name'])['LocationConstraint']))
这将输出每个S3存储桶的名称、创建日期、所有者和位置。其他AWS资源也有类似的公共属性,可以在AWS SDK文档中找到。
上一篇:AWS资源删除状态延迟