选择您的 Cookie 首选项

我们使用必要 Cookie 和类似工具提供我们的网站和服务。我们使用性能 Cookie 收集匿名统计数据,以便我们可以了解客户如何使用我们的网站并进行改进。必要 Cookie 无法停用,但您可以单击“自定义”或“拒绝”来拒绝性能 Cookie。

如果您同意,AWS 和经批准的第三方还将使用 Cookie 提供有用的网站功能、记住您的首选项并显示相关内容,包括相关广告。要接受或拒绝所有非必要 Cookie,请单击“接受”或“拒绝”。要做出更详细的选择,请单击“自定义”。

使用 AWS CLI 的 Macie 示例

聚焦模式
使用 AWS CLI 的 Macie 示例 - AWS Command Line Interface

以下代码示例演示了如何通过将 AWS Command Line Interface与 Macie 结合使用,来执行操作和实现常见场景。

操作是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景的上下文查看操作。

每个示例都包含一个指向完整源代码的链接,您可以从中找到有关如何在上下文中设置和运行代码的说明。

主题

操作

以下代码示例演示如何使用 describe-buckets

AWS CLI

查询 Amazon Macie 为您的账户监控和分析的一个或多个 S3 存储桶的数据

以下 describe-buckets 示例查询名称以 amzn-s3-demo-bucket 开头且位于当前 AWS 区域内的所有 S3 存储桶的元数据。

aws macie2 describe-buckets \ --criteria '{"bucketName":{"prefix":"amzn-s3-demo-bucket"}}'

输出:

{ "buckets": [ { "accountId": "123456789012", "allowsUnencryptedObjectUploads": "FALSE", "automatedDiscoveryMonitoringStatus": "MONITORED", "bucketArn": "arn:aws:s3:::amzn-s3-demo-bucket1", "bucketCreatedAt": "2020-05-18T19:54:00+00:00", "bucketName": "amzn-s3-demo-bucket1", "classifiableObjectCount": 13, "classifiableSizeInBytes": 1592088, "jobDetails": { "isDefinedInJob": "TRUE", "isMonitoredByJob": "TRUE", "lastJobId": "08c81dc4a2f3377fae45c9ddaEXAMPLE", "lastJobRunTime": "2024-08-19T14:55:30.270000+00:00" }, "lastAutomatedDiscoveryTime": "2024-10-22T19:11:25.364000+00:00", "lastUpdated": "2024-10-25T07: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", "automatedDiscoveryMonitoringStatus": "MONITORED", "bucketArn": "arn:aws:s3:::amzn-s3-demo-bucket2", "bucketCreatedAt": "2020-11-25T18:24:38+00:00", "bucketName": "amzn-s3-demo-bucket2", "classifiableObjectCount": 8, "classifiableSizeInBytes": 133810, "jobDetails": { "isDefinedInJob": "TRUE", "isMonitoredByJob": "FALSE", "lastJobId": "188d4f6044d621771ef7d65f2EXAMPLE", "lastJobRunTime": "2024-07-09T19:37:11.511000+00:00" }, "lastAutomatedDiscoveryTime": "2024-10-24T19:11:25.364000+00:00", "lastUpdated": "2024-10-25T07: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

以下代码示例演示如何使用 describe-buckets

AWS CLI

查询 Amazon Macie 为您的账户监控和分析的一个或多个 S3 存储桶的数据

以下 describe-buckets 示例查询名称以 amzn-s3-demo-bucket 开头且位于当前 AWS 区域内的所有 S3 存储桶的元数据。

aws macie2 describe-buckets \ --criteria '{"bucketName":{"prefix":"amzn-s3-demo-bucket"}}'

输出:

{ "buckets": [ { "accountId": "123456789012", "allowsUnencryptedObjectUploads": "FALSE", "automatedDiscoveryMonitoringStatus": "MONITORED", "bucketArn": "arn:aws:s3:::amzn-s3-demo-bucket1", "bucketCreatedAt": "2020-05-18T19:54:00+00:00", "bucketName": "amzn-s3-demo-bucket1", "classifiableObjectCount": 13, "classifiableSizeInBytes": 1592088, "jobDetails": { "isDefinedInJob": "TRUE", "isMonitoredByJob": "TRUE", "lastJobId": "08c81dc4a2f3377fae45c9ddaEXAMPLE", "lastJobRunTime": "2024-08-19T14:55:30.270000+00:00" }, "lastAutomatedDiscoveryTime": "2024-10-22T19:11:25.364000+00:00", "lastUpdated": "2024-10-25T07: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", "automatedDiscoveryMonitoringStatus": "MONITORED", "bucketArn": "arn:aws:s3:::amzn-s3-demo-bucket2", "bucketCreatedAt": "2020-11-25T18:24:38+00:00", "bucketName": "amzn-s3-demo-bucket2", "classifiableObjectCount": 8, "classifiableSizeInBytes": 133810, "jobDetails": { "isDefinedInJob": "TRUE", "isMonitoredByJob": "FALSE", "lastJobId": "188d4f6044d621771ef7d65f2EXAMPLE", "lastJobRunTime": "2024-07-09T19:37:11.511000+00:00" }, "lastAutomatedDiscoveryTime": "2024-10-24T19:11:25.364000+00:00", "lastUpdated": "2024-10-25T07: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

本页内容

隐私网站条款Cookie 首选项
© 2025, Amazon Web Services, Inc. 或其附属公司。保留所有权利。