使用 Amazon CLI 更新事件数据存储 - Amazon CloudTrail
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

使用 Amazon CLI 更新事件数据存储

本节提供的示例演示了如何通过运行 Amazon CLI update-event-data-store 命令来更新事件数据存储的设置。

使用 Amazon CLI 更新计费模式

事件数据存储的 --billing-mode 决定了摄取和存储事件的成本,以及事件数据存储的默认和最长保留期。如果事件数据存储的 --billing-mode 设置为 FIXED_RETENTION_PRICING,则可以将该值更改为 EXTENDABLE_RETENTION_PRICING。如果您的事件数据存储每月摄取的事件数据少于 25TB,并且您希望采用最多 3653 天的灵活保留期,则通常建议使用 EXTENDABLE_RETENTION_PRICING。有关定价的信息,请参阅 Amazon CloudTrail 定价管理 CloudTrail Lake 成本

注意

您不能将 --billing-mode 值从 EXTENDABLE_RETENTION_PRICING 更改为 FIXED_RETENTION_PRICING。如果事件数据存储的计费模式设置为 EXTENDABLE_RETENTION_PRICING,且您想改用 FIXED_RETENTION_PRICING,则可以停止对事件数据存储的摄取,并创建一个使用 FIXED_RETENTION_PRICING 的新事件数据存储。

以下示例 Amazon CLI update-event-data-store 命令将事件数据存储的 --billing-modeFIXED_RETENTION_PRICING 更改为 EXTENDABLE_RETENTION_PRICING。必要的 --event-data-store 参数值是 ARN(或 ARN 的 ID 后缀),且是必填项;其它参数是可选项。

aws cloudtrail update-event-data-store \ --region us-east-1 \ --event-data-store arn:aws:cloudtrail:us-east-1:123456789012:eventdatastore/EXAMPLE-f852-4e8f-8bd1-bcf6cEXAMPLE \ --billing-mode EXTENDABLE_RETENTION_PRICING

以下为响应示例。

{ "EventDataStoreArn": "event-data-store arn:aws:cloudtrail:us-east-1:123456789012:eventdatastore/EXAMPLE-f852-4e8f-8bd1-bcf6cEXAMPLE", "Name": "management-events-eds", "Status": "ENABLED", "AdvancedEventSelectors": [ { "Name": "Default management events", "FieldSelectors": [ { "Field": "eventCategory", "Equals": [ "Management" ] } ] } ], "MultiRegionEnabled": true, "OrganizationEnabled": false, "BillingMode": "EXTENDABLE_RETENTION_PRICING", "RetentionPeriod": 2557, "TerminationProtectionEnabled": true, "CreatedTimestamp": "2023-10-27T10:55:55.384000-04:00", "UpdatedTimestamp": "2023-10-27T10:57:05.549000-04:00" }

更新保留模式,启用终止保护,然后使用 Amazon CLI 指定 Amazon KMS key

以下示例 Amazon CLI update-event-data-store 命令更新事件数据存储,以将其保留期限更改为 100 天,并启用终止保护。必要的 --event-data-store 参数值是 ARN(或 ARN 的 ID 后缀),且是必填项;其它参数是可选项。在此示例中,添加了 --retention-period 参数,以将保留期限更改为 100 天。或者,您可以选择启用 Amazon Key Management Service 加密,然后通过向命令添加 --kms-key-id 并将 KMS 密钥 ARN 指定为值,来指定 Amazon KMS key。添加 --termination-protection-enabled 以在未启用终止保护的事件数据存储上启用终止保护。

记录来自 Amazon 外部事件的事件数据存储无法更新为记录 Amazon 事件。同样,记录 Amazon 事件的事件数据存储也无法更新为记录来自 Amazon 外部的事件。

注意

如果您缩短事件数据存储的保留期,CloudTrail 将删除所有 eventTime 早于新保留期的事件。例如,如果之前的保留期为 365 天,而您将其缩短到 100 天,则 CloudTrail 将删除 eventTime 超过 100 天的事件。

aws cloudtrail update-event-data-store \ --event-data-store arn:aws:cloudtrail:us-east-1:123456789012:eventdatastore/EXAMPLE-f852-4e8f-8bd1-bcf6cEXAMPLE \ --retention-period 100 \ --kms-key-id "arn:aws:kms:us-east-1:0123456789:alias/KMS_key_alias" \ --termination-protection-enabled

以下为响应示例。

{ "EventDataStoreArn": "arn:aws:cloudtrail:us-east-1:123456789012:eventdatastore/EXAMPLE-ee54-4813-92d5-999aeEXAMPLE", "Name": "my-event-data-store", "Status": "ENABLED", "AdvancedEventSelectors": [ { "Name": "Select all S3 data events", "FieldSelectors": [ { "Field": "eventCategory", "Equals": [ "Data" ] }, { "Field": "resources.type", "Equals": [ "AWS::S3::Object" ] }, { "Field": "resources.ARN", "StartsWith": [ "arn:aws:s3" ] } ] } ], "MultiRegionEnabled": true, "OrganizationEnabled": false, "BillingMode": "EXTENDABLE_RETENTION_PRICING", "RetentionPeriod": 100, "KmsKeyId": "arn:aws:kms:us-east-1:0123456789:alias/KMS_key_alias", "TerminationProtectionEnabled": true, "CreatedTimestamp": "2023-10-27T10:55:55.384000-04:00", "UpdatedTimestamp": "2023-10-27T10:57:05.549000-04:00" }

使用 Amazon CLI 禁用终止保护

默认情况下,事件数据存储已启用终止保护,以防止事件数据存储被意外删除。当终止保护启用时,您无法删除事件数据存储。如果要删除事件数据存储,您必须先禁用终止保护。

以下示例 Amazon CLI update-event-data-store 命令通过传递 --no-termination-protection-enabled 参数来禁用终止保护。

aws cloudtrail update-event-data-store \ --region us-east-1 \ --no-termination-protection-enabled \ --event-data-store arn:aws:cloudtrail:us-east-1:123456789012:eventdatastore/EXAMPLE-f852-4e8f-8bd1-bcf6cEXAMPLE

以下为响应示例。

{ "EventDataStoreArn": "arn:aws:cloudtrail:us-east-1:123456789012:eventdatastore/EXAMPLE-f852-4e8f-8bd1-bcf6cEXAMPLE", "Name": "management-events-eds", "Status": "ENABLED", "AdvancedEventSelectors": [ { "Name": "Default management events", "FieldSelectors": [ { "Field": "eventCategory", "Equals": [ "Management" ] } ] } ], "MultiRegionEnabled": true, "OrganizationEnabled": false, "BillingMode": "EXTENDABLE_RETENTION_PRICING", "RetentionPeriod": 366, "TerminationProtectionEnabled": false, "CreatedTimestamp": "2023-10-27T10:55:55.384000-04:00", "UpdatedTimestamp": "2023-10-27T10:57:05.549000-04:00" }