start_export_job_v2
async
¶
start_export_job_v2(
*,
config_overrides: Optional[AsyncSecurityHubClientConfig] = 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.
>>> await 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.
>>> await 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/async_security_hub.py
7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 | |