![](/img/trans.png)
[英]How do you disable S3 Object Logging to Cloud Trail using AWS CLI?
[英]How do you enable S3 Object Logging to Cloud Trail using AWS CLI?
可以使用以下指南在S3存儲桶上將對象記錄到Cloud Trail,但這是通過控制台進行的。
https://docs.aws.amazon.com/AmazonS3/latest/user-guide/enable-cloudtrail-events.html
我一直想通過cli來找到一種方法,因為它想在很多桶中都可以使用,但是運氣還不太好。 我在帳戶上設置了一條新的雲線索,並希望將其映射到s3存儲桶以進行對象記錄。 有這個cli嗎?
# This is to grant s3 log bucket access (no link to cloudtrail here)
aws s3api put-bucket-logging
看來您需要使用CloudTrail put_event_selectors()
命令:
數據資源
CloudTrail支持針對Amazon S3對象和AWS Lambda函數的數據事件日志記錄。
(dict) :您在事件選擇器中指定的Amazon S3存儲桶或AWS Lambda函數,以記錄數據事件。
在文檔頁面中搜索object-level
。
免責聲明: puji
在接受的答案作品中的評論。 這是資源解決方案的擴展。
這是有關如何通過AWS CLI執行此操作的AWS文檔
https://docs.aws.amazon.com/cli/latest/reference/cloudtrail/put-event-selectors.html
您感興趣的特定CLI命令是上述文檔中的以下內容。 原始文檔在同一存儲桶中列出了兩個對象。 我已經對其進行了修改,以涵蓋兩個存儲桶中的所有對象。
aws cloudtrail put-event-selectors --trail-name TrailName --event-selectors '[{"ReadWriteType": "All","IncludeManagementEvents": true,"DataResources": [{"Type":"AWS::S3::Object", "Values": ["arn:aws:s3:::mybucket1/","arn:aws:s3:::mybucket2/"]}]}]'
如果您希望覆蓋AWS賬戶中的所有S3存儲桶,則可以使用arn:aws:s3:::
代替存儲桶arn:aws:s3:::
列表,如下所示。
aws cloudtrail put-event-selectors --trail-name TrailName2 --event-selectors '[{"ReadWriteType": "All","IncludeManagementEvents": true,"DataResources": [{"Type":"AWS::S3::Object", "Values": ["arn:aws:s3:::"]}]}]'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.