Amazon Macie 2

2021/02/08 - Amazon Macie 2 - 3 updated api methods

Changes  Update macie2 client to latest version

DescribeBuckets (updated) Link ¶
Changes (response)
{'buckets': {'serverSideEncryption': {'kmsMasterKeyId': 'string',
                                      'type': 'NONE | AES256 | aws:kms'}}}

Retrieves (queries) statistical data and other information about one or more S3 buckets that Amazon Macie monitors and analyzes.

See also: AWS API Documentation

Request Syntax

client.describe_buckets(
    criteria={
        'string': {
            'eq': [
                'string',
            ],
            'gt': 123,
            'gte': 123,
            'lt': 123,
            'lte': 123,
            'neq': [
                'string',
            ],
            'prefix': 'string'
        }
    },
    maxResults=123,
    nextToken='string',
    sortCriteria={
        'attributeName': 'string',
        'orderBy': 'ASC'|'DESC'
    }
)
type criteria:

dict

param criteria:

The criteria to use to filter the query results.

  • (string) --

    • (dict) --

      Specifies the operator to use in a property-based condition that filters the results of a query for information about S3 buckets.

      • eq (list) --

        The value for the property matches (equals) the specified value. If you specify multiple values, Macie uses OR logic to join the values.

        • (string) --

      • gt (integer) --

        The value for the property is greater than the specified value.

      • gte (integer) --

        The value for the property is greater than or equal to the specified value.

      • lt (integer) --

        The value for the property is less than the specified value.

      • lte (integer) --

        The value for the property is less than or equal to the specified value.

      • neq (list) --

        The value for the property doesn't match (doesn't equal) the specified value. If you specify multiple values, Amazon Macie uses OR logic to join the values.

        • (string) --

      • prefix (string) --

        The name of the bucket begins with the specified value.

type maxResults:

integer

param maxResults:

The maximum number of items to include in each page of the response. The default value is 50.

type nextToken:

string

param nextToken:

The nextToken string that specifies which page of results to return in a paginated response.

type sortCriteria:

dict

param sortCriteria:

The criteria to use to sort the query results.

  • attributeName (string) --

    The name of the property to sort the results by. This value can be the name of any property that Amazon Macie defines as bucket metadata, such as bucketName or accountId.

  • orderBy (string) --

    The sort order to apply to the results, based on the value for the property specified by the attributeName property. Valid values are: ASC, sort the results in ascending order; and, DESC, sort the results in descending order.

rtype:

dict

returns:

Response Syntax

{
    'buckets': [
        {
            'accountId': 'string',
            'bucketArn': 'string',
            'bucketCreatedAt': datetime(2015, 1, 1),
            'bucketName': 'string',
            'classifiableObjectCount': 123,
            'classifiableSizeInBytes': 123,
            'jobDetails': {
                'isDefinedInJob': 'TRUE'|'FALSE'|'UNKNOWN',
                'isMonitoredByJob': 'TRUE'|'FALSE'|'UNKNOWN',
                'lastJobId': 'string',
                'lastJobRunTime': datetime(2015, 1, 1)
            },
            'lastUpdated': datetime(2015, 1, 1),
            'objectCount': 123,
            'objectCountByEncryptionType': {
                'customerManaged': 123,
                'kmsManaged': 123,
                's3Managed': 123,
                'unencrypted': 123
            },
            'publicAccess': {
                'effectivePermission': 'PUBLIC'|'NOT_PUBLIC'|'UNKNOWN',
                'permissionConfiguration': {
                    'accountLevelPermissions': {
                        'blockPublicAccess': {
                            'blockPublicAcls': True|False,
                            'blockPublicPolicy': True|False,
                            'ignorePublicAcls': True|False,
                            'restrictPublicBuckets': True|False
                        }
                    },
                    'bucketLevelPermissions': {
                        'accessControlList': {
                            'allowsPublicReadAccess': True|False,
                            'allowsPublicWriteAccess': True|False
                        },
                        'blockPublicAccess': {
                            'blockPublicAcls': True|False,
                            'blockPublicPolicy': True|False,
                            'ignorePublicAcls': True|False,
                            'restrictPublicBuckets': True|False
                        },
                        'bucketPolicy': {
                            'allowsPublicReadAccess': True|False,
                            'allowsPublicWriteAccess': True|False
                        }
                    }
                }
            },
            'region': 'string',
            'replicationDetails': {
                'replicated': True|False,
                'replicatedExternally': True|False,
                'replicationAccounts': [
                    'string',
                ]
            },
            'serverSideEncryption': {
                'kmsMasterKeyId': 'string',
                'type': 'NONE'|'AES256'|'aws:kms'
            },
            'sharedAccess': 'EXTERNAL'|'INTERNAL'|'NOT_SHARED'|'UNKNOWN',
            'sizeInBytes': 123,
            'sizeInBytesCompressed': 123,
            'tags': [
                {
                    'key': 'string',
                    'value': 'string'
                },
            ],
            'unclassifiableObjectCount': {
                'fileType': 123,
                'storageClass': 123,
                'total': 123
            },
            'unclassifiableObjectSizeInBytes': {
                'fileType': 123,
                'storageClass': 123,
                'total': 123
            },
            'versioning': True|False
        },
    ],
    'nextToken': 'string'
}

Response Structure

  • (dict) --

    The request succeeded.

    • buckets (list) --

      An array of objects, one for each bucket that meets the filter criteria specified in the request.

      • (dict) --

        Provides information about an S3 bucket that Amazon Macie monitors and analyzes.

        • accountId (string) --

          The unique identifier for the AWS account that owns the bucket.

        • bucketArn (string) --

          The Amazon Resource Name (ARN) of the bucket.

        • bucketCreatedAt (datetime) --

          The date and time, in UTC and extended ISO 8601 format, when the bucket was created.

        • bucketName (string) --

          The name of the bucket.

        • classifiableObjectCount (integer) --

          The total number of objects that Amazon Macie can analyze in the bucket. These objects use a supported storage class and have a file name extension for a supported file or storage format.

        • classifiableSizeInBytes (integer) --

          The total storage size, in bytes, of the objects that Amazon Macie can analyze in the bucket. These objects use a supported storage class and have a file name extension for a supported file or storage format.

        • jobDetails (dict) --

          Specifies whether any one-time or recurring classification jobs are configured to analyze data in the bucket, and, if so, the details of the job that ran most recently.

          • isDefinedInJob (string) --

            Specifies whether any one-time or recurring jobs are configured to analyze data in the bucket. Possible values are:

            • TRUE - One or more jobs is configured to analyze data in the bucket, and at least one of those jobs has a status other than CANCELLED.

            • FALSE - No jobs are configured to analyze data in the bucket, or all the jobs that are configured to analyze data in the bucket have a status of CANCELLED.

            • UNKNOWN - An exception occurred when Amazon Macie attempted to retrieve job data for the bucket.

          • isMonitoredByJob (string) --

            Specifies whether any recurring jobs are configured to analyze data in the bucket. Possible values are:

            • TRUE - One or more recurring jobs is configured to analyze data in the bucket, and at least one of those jobs has a status other than CANCELLED.

            • FALSE - No recurring jobs are configured to analyze data in the bucket, or all the recurring jobs that are configured to analyze data in the bucket have a status of CANCELLED.

            • UNKNOWN - An exception occurred when Amazon Macie attempted to retrieve job data for the bucket.

          • lastJobId (string) --

            The unique identifier for the job that ran most recently (either the latest run of a recurring job or the only run of a one-time job) and is configured to analyze data in the bucket.

            This value is null if the value for the isDefinedInJob property is FALSE or UNKNOWN.

          • lastJobRunTime (datetime) --

            The date and time, in UTC and extended ISO 8601 format, when the job (lastJobId) started. If the job is a recurring job, this value indicates when the most recent run started.

            This value is null if the value for the isDefinedInJob property is FALSE or UNKNOWN.

        • lastUpdated (datetime) --

          The date and time, in UTC and extended ISO 8601 format, when Amazon Macie most recently retrieved data about the bucket from Amazon S3.

        • objectCount (integer) --

          The total number of objects in the bucket.

        • objectCountByEncryptionType (dict) --

          The total number of objects that are in the bucket, grouped by server-side encryption type. This includes a grouping that reports the total number of objects that aren't encrypted or use client-side encryption.

          • customerManaged (integer) --

            The total number of objects that are encrypted using a customer-managed key. The objects use customer-provided server-side encryption (SSE-C).

          • kmsManaged (integer) --

            The total number of objects that are encrypted using an AWS Key Management Service (AWS KMS) customer master key (CMK). The objects use AWS managed AWS KMS encryption (AWS-KMS) or customer managed AWS KMS encryption (SSE-KMS).

          • s3Managed (integer) --

            The total number of objects that are encrypted using an Amazon S3 managed key. The objects use Amazon S3 managed encryption (SSE-S3).

          • unencrypted (integer) --

            The total number of objects that aren't encrypted or use client-side encryption.

        • publicAccess (dict) --

          Specifies whether the bucket is publicly accessible due to the combination of permissions settings that apply to the bucket, and provides information about those settings.

          • effectivePermission (string) --

            Specifies whether the bucket is publicly accessible due to the combination of permissions settings that apply to the bucket. Possible values are:

            • NOT_PUBLIC - The bucket isn't publicly accessible.

            • PUBLIC - The bucket is publicly accessible.

            • UNKNOWN - Amazon Macie can't determine whether the bucket is publicly accessible.

          • permissionConfiguration (dict) --

            The account-level and bucket-level permissions for the bucket.

            • accountLevelPermissions (dict) --

              The account-level permissions settings that apply to the bucket.

              • blockPublicAccess (dict) --

                The block public access settings for the AWS account that owns the bucket.

                • blockPublicAcls (boolean) --

                  Specifies whether Amazon S3 blocks public access control lists (ACLs) for the bucket and objects in the bucket.

                • blockPublicPolicy (boolean) --

                  Specifies whether Amazon S3 blocks public bucket policies for the bucket.

                • ignorePublicAcls (boolean) --

                  Specifies whether Amazon S3 ignores public ACLs for the bucket and objects in the bucket.

                • restrictPublicBuckets (boolean) --

                  Specifies whether Amazon S3 restricts public bucket policies for the bucket.

            • bucketLevelPermissions (dict) --

              The bucket-level permissions settings for the bucket.

              • accessControlList (dict) --

                The permissions settings of the access control list (ACL) for the bucket. This value is null if an ACL hasn't been defined for the bucket.

                • allowsPublicReadAccess (boolean) --

                  Specifies whether the ACL grants the general public with read access permissions for the bucket.

                • allowsPublicWriteAccess (boolean) --

                  Specifies whether the ACL grants the general public with write access permissions for the bucket.

              • blockPublicAccess (dict) --

                The block public access settings for the bucket.

                • blockPublicAcls (boolean) --

                  Specifies whether Amazon S3 blocks public access control lists (ACLs) for the bucket and objects in the bucket.

                • blockPublicPolicy (boolean) --

                  Specifies whether Amazon S3 blocks public bucket policies for the bucket.

                • ignorePublicAcls (boolean) --

                  Specifies whether Amazon S3 ignores public ACLs for the bucket and objects in the bucket.

                • restrictPublicBuckets (boolean) --

                  Specifies whether Amazon S3 restricts public bucket policies for the bucket.

              • bucketPolicy (dict) --

                The permissions settings of the bucket policy for the bucket. This value is null if a bucket policy hasn't been defined for the bucket.

                • allowsPublicReadAccess (boolean) --

                  Specifies whether the bucket policy allows the general public to have read access to the bucket.

                • allowsPublicWriteAccess (boolean) --

                  Specifies whether the bucket policy allows the general public to have write access to the bucket.

        • region (string) --

          The AWS Region that hosts the bucket.

        • replicationDetails (dict) --

          Specifies whether the bucket is configured to replicate one or more objects to buckets for other AWS accounts and, if so, which accounts.

          • replicated (boolean) --

            Specifies whether the bucket is configured to replicate one or more objects to any destination.

          • replicatedExternally (boolean) --

            Specifies whether the bucket is configured to replicate one or more objects to an AWS account that isn't part of the same Amazon Macie organization.

          • replicationAccounts (list) --

            An array of AWS account IDs, one for each AWS account that the bucket is configured to replicate one or more objects to.

            • (string) --

        • serverSideEncryption (dict) --

          Specifies whether the bucket encrypts new objects by default and, if so, the type of server-side encryption that's used.

          • kmsMasterKeyId (string) --

            The Amazon Resource Name (ARN) or unique identifier (key ID) for the AWS Key Management Service (AWS KMS) customer master key (CMK) that's used by default to encrypt objects that are added to the bucket. This value is null if the bucket uses an Amazon S3 managed key to encrypt new objects or the bucket doesn't encrypt new objects by default.

          • type (string) --

            The type of server-side encryption that's used by default when storing new objects in the bucket. Possible values are:

            • AES256 - New objects are encrypted with an Amazon S3 managed key and use Amazon S3 managed encryption (SSE-S3).

            • aws:kms - New objects are encrypted with an AWS KMS CMK, specified by the kmsMasterKeyId property, and use AWS managed AWS KMS encryption (AWS-KMS) or customer managed AWS KMS encryption (SSE-KMS).

            • NONE - New objects aren't encrypted by default. Default encryption is disabled for the bucket.

        • sharedAccess (string) --

          Specifies whether the bucket is shared with another AWS account. Possible values are:

          • EXTERNAL - The bucket is shared with an AWS account that isn't part of the same Amazon Macie organization.

          • INTERNAL - The bucket is shared with an AWS account that's part of the same Amazon Macie organization.

          • NOT_SHARED - The bucket isn't shared with other AWS accounts.

          • UNKNOWN - Amazon Macie wasn't able to evaluate the shared access settings for the bucket.

        • sizeInBytes (integer) --

          The total storage size, in bytes, of the bucket.

        • sizeInBytesCompressed (integer) --

          The total compressed storage size, in bytes, of the bucket.

        • tags (list) --

          An array that specifies the tags (keys and values) that are associated with the bucket.

          • (dict) --

            Provides information about the tags that are associated with an S3 bucket or object. Each tag consists of a required tag key and an associated tag value.

            • key (string) --

              One part of a key-value pair that comprises a tag. A tag key is a general label that acts as a category for more specific tag values.

            • value (string) --

              One part of a key-value pair that comprises a tag. A tag value acts as a descriptor for a tag key. A tag value can be an empty string.

        • unclassifiableObjectCount (dict) --

          The total number of objects that Amazon Macie can't analyze in the bucket. These objects don't use a supported storage class or don't have a file name extension for a supported file or storage format.

          • fileType (integer) --

            The total storage size (in bytes) or number of objects that Amazon Macie can't analyze because the objects don't have a file name extension for a supported file or storage format.

          • storageClass (integer) --

            The total storage size (in bytes) or number of objects that Amazon Macie can't analyze because the objects use an unsupported storage class.

          • total (integer) --

            The total storage size (in bytes) or number of objects that Amazon Macie can't analyze because the objects use an unsupported storage class or don't have a file name extension for a supported file or storage format.

        • unclassifiableObjectSizeInBytes (dict) --

          The total storage size, in bytes, of the objects that Amazon Macie can't analyze in the bucket. These objects don't use a supported storage class or don't have a file name extension for a supported file or storage format.

          • fileType (integer) --

            The total storage size (in bytes) or number of objects that Amazon Macie can't analyze because the objects don't have a file name extension for a supported file or storage format.

          • storageClass (integer) --

            The total storage size (in bytes) or number of objects that Amazon Macie can't analyze because the objects use an unsupported storage class.

          • total (integer) --

            The total storage size (in bytes) or number of objects that Amazon Macie can't analyze because the objects use an unsupported storage class or don't have a file name extension for a supported file or storage format.

        • versioning (boolean) --

          Specifies whether versioning is enabled for the bucket.

    • nextToken (string) --

      The string to use in a subsequent request to get the next page of results in a paginated response. This value is null if there are no additional pages.

GetUsageStatistics (updated) Link ¶
Changes (both)
{'timeRange': 'MONTH_TO_DATE | PAST_30_DAYS'}

Retrieves (queries) quotas and aggregated usage data for one or more accounts.

See also: AWS API Documentation

Request Syntax

client.get_usage_statistics(
    filterBy=[
        {
            'comparator': 'GT'|'GTE'|'LT'|'LTE'|'EQ'|'NE'|'CONTAINS',
            'key': 'accountId'|'serviceLimit'|'freeTrialStartDate'|'total',
            'values': [
                'string',
            ]
        },
    ],
    maxResults=123,
    nextToken='string',
    sortBy={
        'key': 'accountId'|'total'|'serviceLimitValue'|'freeTrialStartDate',
        'orderBy': 'ASC'|'DESC'
    },
    timeRange='MONTH_TO_DATE'|'PAST_30_DAYS'
)
type filterBy:

list

param filterBy:

An array of objects, one for each condition to use to filter the query results. If you specify more than one condition, Amazon Macie uses an AND operator to join the conditions.

  • (dict) --

    Specifies a condition for filtering the results of a query for the quotas and usage data that applies to one or more Amazon Macie accounts.

    • comparator (string) --

      The operator to use in the condition. If the value for the key property is accountId, this value must be CONTAINS. If the value for the key property is any other supported field, this value can be EQ, GT, GTE, LT, LTE, or NE.

    • key (string) --

      The field to use in the condition.

    • values (list) --

      An array that lists values to use in the condition, based on the value for the field specified by the key property. If the value for the key property is accountId, this array can specify multiple values. Otherwise, this array can specify only one value.

      Valid values for each supported field are:

      • accountId - The unique identifier for an AWS account.

      • freeTrialStartDate - The date and time, in UTC and extended ISO 8601 format, when the free trial started for an account.

      • serviceLimit - A Boolean (true or false) value that indicates whether an account has reached its monthly quota.

      • total - A string that represents the current, estimated month-to-date cost for an account.

      • (string) --

type maxResults:

integer

param maxResults:

The maximum number of items to include in each page of the response.

type nextToken:

string

param nextToken:

The nextToken string that specifies which page of results to return in a paginated response.

type sortBy:

dict

param sortBy:

The criteria to use to sort the query results.

  • key (string) --

    The field to sort the results by.

  • orderBy (string) --

    The sort order to apply to the results, based on the value for the field specified by the key property. Valid values are: ASC, sort the results in ascending order; and, DESC, sort the results in descending order.

type timeRange:

string

param timeRange:

The inclusive time period to query usage data for. Valid values are: MONTH_TO_DATE, for the current calendar month to date; and, PAST_30_DAYS, for the preceding 30 days. If you don't specify a value, Amazon Macie provides usage data for the preceding 30 days.

rtype:

dict

returns:

Response Syntax

{
    'nextToken': 'string',
    'records': [
        {
            'accountId': 'string',
            'freeTrialStartDate': datetime(2015, 1, 1),
            'usage': [
                {
                    'currency': 'USD',
                    'estimatedCost': 'string',
                    'serviceLimit': {
                        'isServiceLimited': True|False,
                        'unit': 'TERABYTES',
                        'value': 123
                    },
                    'type': 'DATA_INVENTORY_EVALUATION'|'SENSITIVE_DATA_DISCOVERY'
                },
            ]
        },
    ],
    'timeRange': 'MONTH_TO_DATE'|'PAST_30_DAYS'
}

Response Structure

  • (dict) --

    The request succeeded.

    • nextToken (string) --

      The string to use in a subsequent request to get the next page of results in a paginated response. This value is null if there are no additional pages.

    • records (list) --

      An array of objects that contains the results of the query. Each object contains the data for an account that meets the filter criteria specified in the request.

      • (dict) --

        Provides quota and aggregated usage data for an Amazon Macie account.

        • accountId (string) --

          The unique identifier for the AWS account that the data applies to.

        • freeTrialStartDate (datetime) --

          The date and time, in UTC and extended ISO 8601 format, when the free trial started for the account.

        • usage (list) --

          An array of objects that contains usage data and quotas for the account. Each object contains the data for a specific usage metric and the corresponding quota.

          • (dict) --

            Provides data for a specific usage metric and the corresponding quota for an Amazon Macie account.

            • currency (string) --

              The type of currency that the value for the metric (estimatedCost) is reported in.

            • estimatedCost (string) --

              The estimated value for the metric.

            • serviceLimit (dict) --

              The current value for the quota that corresponds to the metric specified by the type field.

              • isServiceLimited (boolean) --

                Specifies whether the account has met the quota that corresponds to the metric specified by the UsageByAccount.type field in the response.

              • unit (string) --

                The unit of measurement for the value specified by the value field.

              • value (integer) --

                The value for the metric specified by the UsageByAccount.type field in the response.

            • type (string) --

              The name of the metric. Possible values are: DATA_INVENTORY_EVALUATION, for monitoring S3 buckets; and, SENSITIVE_DATA_DISCOVERY, for analyzing S3 objects to detect sensitive data.

    • timeRange (string) --

      The inclusive time period that the usage data applies to. Possible values are: MONTH_TO_DATE, for the current calendar month to date; and, PAST_30_DAYS, for the preceding 30 days.

GetUsageTotals (updated) Link ¶
Changes (request, response)
Request
{'timeRange': 'string'}
Response
{'timeRange': 'MONTH_TO_DATE | PAST_30_DAYS'}

Retrieves (queries) aggregated usage data for an account.

See also: AWS API Documentation

Request Syntax

client.get_usage_totals(
    timeRange='string'
)
type timeRange:

string

param timeRange:

The time period to retrieve the data for. Valid values are: MONTH_TO_DATE, for the current calendar month to date; and, PAST_30_DAYS, for the preceding 30 days. If you don’t specify a value for this parameter, Amazon Macie provides aggregated usage data for the preceding 30 days.

rtype:

dict

returns:

Response Syntax

{
    'timeRange': 'MONTH_TO_DATE'|'PAST_30_DAYS',
    'usageTotals': [
        {
            'currency': 'USD',
            'estimatedCost': 'string',
            'type': 'DATA_INVENTORY_EVALUATION'|'SENSITIVE_DATA_DISCOVERY'
        },
    ]
}

Response Structure

  • (dict) --

    The request succeeded.

    • timeRange (string) --

      The inclusive time period that the usage data applies to. Possible values are: MONTH_TO_DATE, for the current calendar month to date; and, PAST_30_DAYS, for the preceding 30 days.

    • usageTotals (list) --

      An array of objects that contains the results of the query. Each object contains the data for a specific usage metric.

      • (dict) --

        Provides aggregated data for an Amazon Macie usage metric. The value for the metric reports estimated usage data for an account for the preceding 30 days or the current calendar month to date, depending on the time period (timeRange) specified in the request.

        • currency (string) --

          The type of currency that the value for the metric (estimatedCost) is reported in.

        • estimatedCost (string) --

          The estimated value for the metric.

        • type (string) --

          The name of the metric. Possible values are: DATA_INVENTORY_EVALUATION, for monitoring S3 buckets; and, SENSITIVE_DATA_DISCOVERY, for analyzing S3 objects to detect sensitive data.