View a markdown version of this page

创建批量操作作业以更新对象加密 - Amazon Simple Storage Service
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

创建批量操作作业以更新对象加密

要使用单个请求更新多个 Amazon S3 对象的服务器端加密类型,您可以使用 S3 批量操作。可以通过 Amazon S3 控制台、Amazon Command Line Interface(Amazon CLI)、Amazon SDK 或 Amazon S3 REST API 使用 S3 批量操作。

要运行以下命令,您必须安装并配置 Amazon CLI。如果未安装 Amazon CLI,请参阅《Amazon Command Line Interface 用户指南》中的安装或更新最新版本的 Amazon CLI

或者,可以从控制台中使用 Amazon CloudShell 运行 Amazon CLI 命令。Amazon CloudShell 是一个基于浏览器、预先经过身份验证的 Shell,您可以直接从 Amazon Web Services 管理控制台中启动它。有关更多信息,请参阅《Amazon CloudShell 用户指南》中的 What is CloudShell?Getting started with Amazon CloudShell

例 1 – 创建一个批量操作作业,该作业将加密的对象从一个 Amazon KMS key更新为另一个 KMS 密钥

以下示例说明如何创建一个 S3 批量操作作业,该作业更新通用存储桶中多个对象的加密设置。此命令创建一个作业,该作业将使用一个 Amazon Key Management Service(Amazon KMS)密钥加密的对象更改为使用不同的 KMS 密钥。此作业还会生成和保存受影响对象的清单,并创建结果报告。要使用此命令,请将 user input placeholders 替换为您自己的信息。

aws s3control create-job --account-id account-id \ --no-confirmation-required \ --operation '{"S3UpdateObjectEncryption": { "ObjectEncryption": { "SSEKMS": { "KMSKeyArn": "KMS-key-ARN-to-apply", "BucketKeyEnabled": false } } } }' \ --report '{ "Enabled": true, "Bucket": "report-bucket-ARN", "Format": "Report_CSV_20180820", "Prefix": "report", "ReportScope": "AllTasks" }' \ --manifest-generator '{ "S3JobManifestGenerator": { "ExpectedBucketOwner": "account-id", "SourceBucket": "source-bucket-ARN", "EnableManifestOutput": true, "ManifestOutputLocation": { "Bucket": "manifest-bucket-ARN", "ManifestFormat": "S3InventoryReport_CSV_20211130", "ManifestPrefix": "manifest-prefix" }, "Filter": { "MatchAnyObjectEncryption": [{ "SSEKMS": { "KmsKeyArn": "kms-key-ARN-to-match" } }] } } }' \ --priority 1 \ --role-arn batch-operations-role-ARN

为了获得最佳性能,我们建议将 KmsKeyArn 筛选条件与其它对象元数据筛选条件(例如 MatchAnyPrefixCreatedAfterMatchAnyStorageClass)结合使用。

例 2 – 创建一个批量操作作业,该作业将 SSE-S3 加密的对象更新为 SSE-KMS

以下示例说明如何创建一个 S3 批量操作作业,该作业更新通用存储桶中多个对象的加密设置。此命令创建一个作业,该作业将使用具有 Amazon S3 托管式密钥的服务器端加密(SSE-S3)加密的对象更改为使用具有 Amazon Key Management Service(Amazon KMS)密钥的服务器端加密(SSE-KMS)。此作业还会生成和保存受影响对象的清单,并创建结果报告。要使用此命令,请将 user input placeholders 替换为您自己的信息。

aws s3control create-job --account-id account-id \ --no-confirmation-required \ --operation '{"S3UpdateObjectEncryption": { "ObjectEncryption": { "SSEKMS": { "KMSKeyArn": "KMS-key-ARN-to-apply", "BucketKeyEnabled": false } } } }' \ --report '{ "Enabled": true, "Bucket": "report-bucket-ARN", "Format": "Report_CSV_20180820", "Prefix": "report", "ReportScope": "AllTasks" }' \ --manifest-generator '{ "S3JobManifestGenerator": { "ExpectedBucketOwner": "account-id", "SourceBucket": "source-bucket-ARN", "EnableManifestOutput": true, "ManifestOutputLocation": { "Bucket": "manifest-bucket-ARN", "ManifestFormat": "S3InventoryReport_CSV_20211130", "ManifestPrefix": "manifest-prefix" }, "Filter": { "MatchAnyObjectEncryption": [{ "SSES3": {} }] } } }' \ --priority 1 \ --role-arn batch-operations-role-ARN

为了获得最佳性能,我们建议将 KmsKeyArn 筛选条件与其它对象元数据筛选条件(例如 MatchAnyPrefixCreatedAfterMatchAnyStorageClass)结合使用。