start_export_job_v2
¶
start_export_job_v2(
*,
config_overrides: Optional[SecurityHubClientConfig] = None,
name: Optional[ExportName] = None,
destination: Optional[ExportDestination] = None,
output_configuration: Optional[ExportOutput] = None,
scopes: Optional[ExportScopes] = None,
client_token: Optional[ClientToken] = None,
) -> StartExportJobV2Response
Starts an ad hoc export job that writes Security Hub findings to an Amazon Simple Storage Service (Amazon S3) bucket that you own. Because the export runs asynchronously, this operation returns only the ExportJobId of the new job; it doesn't wait for the export to finish. Use GetExportJobV2 to poll the job, and ListExportJobsV2 to view the export jobs in your account.
Security Hub allows only one export job in the RUNNING state per account at a time. If an export job is already running, this operation returns a ServiceQuotaExceededException. Wait for the running job to finish, or cancel it with CancelExportJobV2, before you start a new one.
Specify the destination bucket and Amazon Web Services Key Management Service (Amazon Web Services KMS) key in the Destination parameter, and the output format (CSV or OCSF_JSON), optional filters, and field selection in the OutputConfiguration parameter. Before you call this operation, you must grant Security Hub permission to write to your bucket and use your Amazon Web Services KMS key by adding the bucket policy and key policy statements shown in the Examples section.
Two identities use your Amazon Web Services KMS key, and each needs its own permission. Security Hub uses the key when it writes the export objects to your bucket. The IAM principal that calls StartExportJobV2 must also have kms:GenerateDataKey and kms:Decrypt permissions on the key. The Examples section shows both grants.
A delegated administrator can use the optional Scopes parameter to export findings for specific organizations or organizational units (OUs).
To make the request idempotent, provide a ClientToken. If you retry a StartExportJobV2 request with the same ClientToken and the same request parameters, Security Hub returns the ExportJobId of the original job instead of starting a new one. If you reuse a ClientToken with different request parameters, this operation returns a ConflictException.
Parameters:
-
name(Optional[ExportName], default:None) –An optional, user-provided name for the export job that helps you identify it in
ListExportJobsV2results. The value can be 1–256 characters. Alphanumeric characters, spaces, and the following ASCII characters are permitted:. _ , : ( ) / + -. -
destination(Optional[ExportDestination], default:None) –The destination that Security Hub writes the export to. You must specify exactly one destination type. Currently, the only supported type is Amazon S3.
-
output_configuration(Optional[ExportOutput], default:None) –Specifies what data to export and how to format it. You must specify exactly one output type. Currently, the only supported type is
Findings. -
scopes(Optional[ExportScopes], default:None) –Limits the export to findings from specific organizational units (OUs) or from the delegated administrator's organization. Only the delegated administrator account can use this parameter; other accounts that specify it receive an
AccessDeniedException.This parameter is optional. If you omit it, the delegated administrator exports findings from all accounts across the entire organization, and other accounts export only their own findings.
You can specify up to 10 entries in
Scopes.AwsOrganizations. If you specify multiple entries, Security Hub combines them using OR logic. -
client_token(Optional[ClientToken], default:None) –A unique identifier used to ensure idempotency.
Raises:
-
AccessDeniedException–You don't have permission to perform the action specified in the request.
-
ConflictException–The request causes conflict with the current state of the service resource.
-
InternalServerException–The request has failed due to an internal failure of the service.
-
OrganizationalUnitNotFoundException–The request failed because one or more organizational units specified in the request don't exist within the caller's organization.
-
OrganizationNotFoundException–The request failed because one or more organizations specified in the request don't exist or don't belong to the caller's organization.
-
ServiceQuotaExceededException–The request was rejected because it would exceed the service quota limit.
-
ThrottlingException–The limit on the number of requests per second was exceeded.
-
ValidationException–The request has failed validation because it's missing required fields or has invalid inputs.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
Example – Starting a CSV export of critical findings The following example starts an export that writes selected fields of new, critical findings to an Amazon S3 bucket in CSV format.
>>> client.start_export_job_v2(name='quarterly-critical-findings', destination={'S3': {'BucketArn': 'arn:aws:s3:::amzn-s3-demo-bucket', 'KmsKeyArn': 'arn:aws:kms:aa-example-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab', 'ObjectPrefix': 'security-hub-exports/2026-Q1'}}, output_configuration={'Findings': {'Format': 'CSV', 'SelectedFields': ['finding_info.title', 'severity', 'status', 'cloud.account.uid', 'resources.uid'], 'Filters': {'CompositeOperator': 'AND', 'CompositeFilters': [{'Operator': 'AND', 'StringFilters': [{'FieldName': 'severity', 'Filter': {'Value': 'Critical', 'Comparison': 'EQUALS'}}, {'FieldName': 'status', 'Filter': {'Value': 'New', 'Comparison': 'EQUALS'}}]}]}}}, client_token='b3d1f9a2-1c4e-4b9a-9f2e-EXAMPLE11111')
Example – Starting an OCSF JSON export scoped to an organizational unit
The following example, run by a delegated administrator, starts an export of the last 30 days of findings for a specific organizational unit (OU) in OCSF JSON format.
>>> client.start_export_job_v2(destination={'S3': {'BucketArn': 'arn:aws:s3:::amzn-s3-demo-bucket', 'KmsKeyArn': 'arn:aws:kms:aa-example-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab'}}, output_configuration={'Findings': {'Format': 'OCSF_JSON', 'Filters': {'CompositeOperator': 'AND', 'CompositeFilters': [{'Operator': 'AND', 'DateFilters': [{'FieldName': 'finding_info.last_seen_time_dt', 'Filter': {'DateRange': {'Value': 30, 'Unit': 'DAYS', 'Comparison': 'WITHIN'}}}]}]}}}, scopes={'AwsOrganizations': [{'OrganizationalUnitId': 'ou-1234-a1b2c3d4'}]})
Source code in docs_src/capo_securityhub/_services/security_hub.py
7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 | |