小编zee*_*123的帖子

boto3 aws检查s3存储桶是否已加密

我在下面发布了以下代码,该代码获取了aws上的所有s3存储桶列表,并且我正在尝试编写代码以检查存储桶是否已在python中加密,但是我很难弄清楚该怎么做。谁能告诉我如何修改我的代码来做到这一点。我尝试了在线示例,并查看了文档。

我的代码是:从将来导入print_function import boto3 import os

 os.environ['AWS_DEFAULT_REGION'] = "us-east-1"
 # Create an S3 client
 s3 = boto3.client('s3')
 # Call S3 to list current buckets

 response = s3.list_buckets()

 # Get a list of all bucket names from the response
 buckets = [bucket['Name'] for bucket in response['Buckets']]

 # Print out the bucket list
 print("Bucket List: %s" % buckets)
Run Code Online (Sandbox Code Playgroud)

尝试了以下代码,但它们不起作用:

 s3 = boto3.resource('s3')
 bucket = s3.Bucket('my-bucket-name')
 for obj in bucket.objects.all():
     key = s3.Object(bucket.name, obj.key)
     print key.server_side_encryption
Run Code Online (Sandbox Code Playgroud)

 #!/usr/bin/env python
 import boto3 …
Run Code Online (Sandbox Code Playgroud)

python encryption amazon-web-services boto3

2
推荐指数
1
解决办法
993
查看次数

标签 统计

amazon-web-services ×1

boto3 ×1

encryption ×1

python ×1