gpt4 book ai didi

python - 从 S3 读取 KMS 加密文件

转载 作者:行者123 更新时间:2023-12-04 11:56:00 27 4
gpt4 key购买 nike

如何使用 boto3 资源从 S3 存储桶读取 KMS 加密文件?

下面是我用来读取非加密文件的片段 -

s3 = boto3.resource('s3')
obj = s3.Object(bucket_name, key)
body = obj.get()['Body'].read()
print(' body = {}'.format(body))

最佳答案

Do I need to specify the AWS KMS key when I download a KMS-encrypted object from Amazon S3? 有一个有用的答案

No, you don’t need to specify the AWS KMS key ID when you download an SSE-KMS-encrypted object from an S3 bucket. Instead, you need the permission to decrypt the AWS KMS key.



因此,除非您正在执行 CMK,否则您不需要在 GetObject 请求上提供 KMS 信息(这是 boto3 资源级方法在幕后所做的)。 .您只需要获得访问 KMS key 的权限即可进行解密。 S3/KMS 将为您完成剩下的工作。

您可以根据链接的文章配置与 Lambda 函数的 IAM 角色关联的 IAM 策略。

关于python - 从 S3 读取 KMS 加密文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55960665/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com