文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
使用 的 Macie 範例 AWS CLI
下列程式碼範例示範如何使用 AWS Command Line Interface 搭配 Macie 來執行動作和實作常見案例。
Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然 動作會示範如何呼叫個別服務函數,但您可以在其相關案例中查看內容中的動作。
每個範例都包含完整原始程式碼的連結,您可以在其中找到如何在內容中設定和執行程式碼的指示。
主題
動作
下列程式碼範例示範如何使用 describe-buckets
。
- AWS CLI
-
查詢 Amazon Macie 監控和分析您帳戶的一或多個 S3 儲存貯體的資料
下列
describe-buckets
範例會查詢名稱以 MY-S3 開頭,且位於目前 AWS 區域中的所有 S3 儲存貯體的中繼資料。 MY-S3aws macie2 describe-buckets \ --criteria '
{"bucketName":{"prefix":"my-S3"}}
'輸出:
{ "buckets": [ { "accountId": "123456789012", "allowsUnencryptedObjectUploads": "FALSE", "bucketArn": "arn:aws:s3:::MY-S3-DOC-EXAMPLE-BUCKET1", "bucketCreatedAt": "2020-05-18T19:54:00+00:00", "bucketName": "MY-S3-DOC-EXAMPLE-BUCKET1", "classifiableObjectCount": 13, "classifiableSizeInBytes": 1592088, "jobDetails": { "isDefinedInJob": "TRUE", "isMonitoredByJob": "TRUE", "lastJobId": "08c81dc4a2f3377fae45c9ddaexample", "lastJobRunTime": "2021-04-26T14:55:30.270000+00:00" }, "lastAutomatedDiscoveryTime": "2022-12-10T19:11:25.364000+00:00", "lastUpdated": "2022-12-13T07:33:06.337000+00:00", "objectCount": 13, "objectCountByEncryptionType": { "customerManaged": 0, "kmsManaged": 2, "s3Managed": 7, "unencrypted": 4, "unknown": 0 }, "publicAccess": { "effectivePermission": "NOT_PUBLIC", "permissionConfiguration": { "accountLevelPermissions": { "blockPublicAccess": { "blockPublicAcls": true, "blockPublicPolicy": true, "ignorePublicAcls": true, "restrictPublicBuckets": true } }, "bucketLevelPermissions": { "accessControlList": { "allowsPublicReadAccess": false, "allowsPublicWriteAccess": false }, "blockPublicAccess": { "blockPublicAcls": true, "blockPublicPolicy": true, "ignorePublicAcls": true, "restrictPublicBuckets": true }, "bucketPolicy": { "allowsPublicReadAccess": false, "allowsPublicWriteAccess": false } } } }, "region": "us-west-2", "replicationDetails": { "replicated": false, "replicatedExternally": false, "replicationAccounts": [] }, "sensitivityScore": 78, "serverSideEncryption": { "kmsMasterKeyId": null, "type": "NONE" }, "sharedAccess": "NOT_SHARED", "sizeInBytes": 4549746, "sizeInBytesCompressed": 0, "tags": [ { "key": "Division", "value": "HR" }, { "key": "Team", "value": "Recruiting" } ], "unclassifiableObjectCount": { "fileType": 0, "storageClass": 0, "total": 0 }, "unclassifiableObjectSizeInBytes": { "fileType": 0, "storageClass": 0, "total": 0 }, "versioning": true }, { "accountId": "123456789012", "allowsUnencryptedObjectUploads": "TRUE", "bucketArn": "arn:aws:s3:::MY-S3-DOC-EXAMPLE-BUCKET2", "bucketCreatedAt": "2020-11-25T18:24:38+00:00", "bucketName": "MY-S3-DOC-EXAMPLE-BUCKET2", "classifiableObjectCount": 8, "classifiableSizeInBytes": 133810, "jobDetails": { "isDefinedInJob": "TRUE", "isMonitoredByJob": "FALSE", "lastJobId": "188d4f6044d621771ef7d65f2example", "lastJobRunTime": "2021-04-09T19:37:11.511000+00:00" }, "lastAutomatedDiscoveryTime": "2022-12-12T19:11:25.364000+00:00", "lastUpdated": "2022-12-13T07:33:06.337000+00:00", "objectCount": 8, "objectCountByEncryptionType": { "customerManaged": 0, "kmsManaged": 0, "s3Managed": 8, "unencrypted": 0, "unknown": 0 }, "publicAccess": { "effectivePermission": "NOT_PUBLIC", "permissionConfiguration": { "accountLevelPermissions": { "blockPublicAccess": { "blockPublicAcls": true, "blockPublicPolicy": true, "ignorePublicAcls": true, "restrictPublicBuckets": true } }, "bucketLevelPermissions": { "accessControlList": { "allowsPublicReadAccess": false, "allowsPublicWriteAccess": false }, "blockPublicAccess": { "blockPublicAcls": true, "blockPublicPolicy": true, "ignorePublicAcls": true, "restrictPublicBuckets": true }, "bucketPolicy": { "allowsPublicReadAccess": false, "allowsPublicWriteAccess": false } } } }, "region": "us-west-2", "replicationDetails": { "replicated": false, "replicatedExternally": false, "replicationAccounts": [] }, "sensitivityScore": 95, "serverSideEncryption": { "kmsMasterKeyId": null, "type": "AES256" }, "sharedAccess": "EXTERNAL", "sizeInBytes": 175978, "sizeInBytesCompressed": 0, "tags": [ { "key": "Division", "value": "HR" }, { "key": "Team", "value": "Recruiting" } ], "unclassifiableObjectCount": { "fileType": 3, "storageClass": 0, "total": 3 }, "unclassifiableObjectSizeInBytes": { "fileType": 2999826, "storageClass": 0, "total": 2999826 }, "versioning": true } ] }
如需詳細資訊,請參閱 Amazon Macie 使用者指南中的篩選 S3 儲存貯體庫存。
-
如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DescribeBuckets
。
-