gcloud alpha asset export

NAME
gcloud alpha asset export - export the cloud assets to Google Cloud Storage/BigQuery
SYNOPSIS
gcloud alpha asset export (--folder=FOLDER_ID     | --organization=ORGANIZATION_ID     | --project=PROJECT_ID) (--output-path=OUTPUT_PATH     | --output-path-prefix=OUTPUT_PATH_PREFIX     | [(--bigquery-table=BIGQUERY_TABLE : --bigquery-dataset=BIGQUERY_DATASET) : --output-bigquery-force --partition-key=PARTITION_KEY --per-asset-type]) [--asset-types=[ASSET_TYPES,…]] [--content-type=CONTENT_TYPE] [--relationship-types=[RELATIONSHIP_TYPES,…]] [--snapshot-time=SNAPSHOT_TIME] [GCLOUD_WIDE_FLAG]
DESCRIPTION
(ALPHA) Export the cloud assets to Google Cloud Storage or BigQuery. Use gcloud asset operations describe to get the latest status of the operation. Note that to export a project different from the project you want to bill, you can use --billing-project or authenticate with a service account. See https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/gcloud-asset for examples of using a service account.
EXAMPLES
To export a snapshot of assets of type 'compute.googleapis.com/Disk' in project 'test-project' at '2019-03-05T00:00:00Z' to 'gs://bucket-name/object-name' and only export the asset metadata, run:
gcloud alpha asset export --project='test-project' --asset-types='compute.googleapis.com/Disk' --snapshot-time='2019-03-05T00:00:00Z' --output-path='gs://bucket-name/object-name' --content-type='resource'

To export a snapshot of assets of type 'compute.googleapis.com/Disk' in project 'test-project' at '2019-03-05T00:00:00Z' to 'projects/projectId/datasets/datasetId/tables/table_name', overwrite the table if existed, run:

gcloud alpha asset export --project='test-project' --asset-types='compute.googleapis.com/Disk' --snapshot-time='2019-03-05T00:00:00Z' --bigquery-table='projects/projectId/datasets/datasetId/tables/table_name' --output-bigquery-force --content-type='resource'
REQUIRED FLAGS
Exactly one of these must be specified:
--folder=FOLDER_ID
The ID of the folder which is the root asset.
--organization=ORGANIZATION_ID
The ID of the organization which is the root asset.
--project=PROJECT_ID
The project which is the root asset.

The Google Cloud project ID to use for this invocation. If omitted, then the current project is assumed; the current project can be listed using gcloud config list --format='text(core.project)' and can be set using gcloud config set project PROJECTID.

--project and its fallback core/project property play two roles in the invocation. It specifies the project of the resource to operate on. It also specifies the project for API enablement check, quota, and billing. To specify a different project for quota and billing, use --billing-project or billing/quota_project property.

The destination path for exporting assets.

Exactly one of these must be specified:

--output-path=OUTPUT_PATH
Google Cloud Storage URI where the results will go. URI must start with "gs://". For example, "gs://bucket_name/object_name"
--output-path-prefix=OUTPUT_PATH_PREFIX
Google Cloud Storage URI where the results will go. URI must start with "gs://". For example, "gs://bucket_name/object_name_prefix", in which case each exported object uri is in format: "gs://bucket_name/object_name_prefix/<asset type>/<shard number>" and it only contains assets for that type.
The BigQuery destination for exporting assets.
--output-bigquery-force
If the destination table already exists and this flag is specified, the table will be overwritten by the contents of assets snapshot. If the flag is not specified and the destination table already exists, the export call returns an error.
--partition-key=PARTITION_KEY
If specified. the snapshot results will be written to partitioned table(s) with two additional timestamp columns, readTime and requestTime, one of which will be the partition key. PARTITION_KEY must be one of: read-time, request-time.
--per-asset-type
If the flag is specified, the snapshot results will be written to one or more tables, each of which contains results of one asset type.
Table resource - The bigquery-table export to. The arguments in this group can be used to specify the attributes of this resource. (NOTE) Some attributes are not given arguments in this group but can be set in other ways.

To set the project attribute:

  • provide the argument --bigquery-table on the command line with a fully specified name;
  • provide the argument --project on the command line;
  • set the property core/project.

This must be specified.

--bigquery-table=BIGQUERY_TABLE
ID of the table or fully qualified identifier for the table.

To set the table attribute:

  • provide the argument --bigquery-table on the command line.

This flag argument must be specified if any of the other arguments in this group are specified.

--bigquery-dataset=BIGQUERY_DATASET
The id of the BigQuery dataset.

To set the bigquery-dataset attribute:

  • provide the argument --bigquery-table on the command line with a fully specified name;
  • provide the argument --bigquery-dataset on the command line.
OPTIONAL FLAGS
--asset-types=[ASSET_TYPES,…]
A list of asset types (i.e., "compute.googleapis.com/Disk") to take a snapshot. If specified and non-empty, only assets matching the specified types will be returned. See http://cloud.google.com/asset-inventory/docs/supported-asset-types for supported asset types.
--content-type=CONTENT_TYPE
Asset content type. If specified, only content matching the specified type will be returned. Otherwise, no content but the asset name will be returned. Specifying resource will export resource metadata, specifying iam-policy will export the IAM policy for each child asset, specifying org-policy will export the Org Policy set on child assets, specifying access-policy will export the Access Policy set on child assets, specifying os-inventory will export the OS inventory of VM instances, and specifying relationship will export relationships of the assets. CONTENT_TYPE must be one of: resource, iam-policy, org-policy, access-policy, os-inventory, relationship.
--relationship-types=[RELATIONSHIP_TYPES,…]
A list of relationship types (i.e., "INSTANCE_TO_INSTANCEGROUP") to take a snapshot. This argument will only be honoured if content_type=RELATIONSHIP. If specified and non-empty, only relationships matching the specified types will be returned. See http://cloud.google.com/asset-inventory/docs/supported-asset-types for supported relationship types.
--snapshot-time=SNAPSHOT_TIME
Timestamp to take a snapshot on assets. This can only be a current or past time. If not specified, the current time will be used. Due to delays in resource data collection and indexing, there is a volatile window during which running the same query at different times may return different results. See $ gcloud topic datetimes for information on time formats.
GCLOUD WIDE FLAGS
These flags are available to all commands: --access-token-file, --account, --billing-project, --configuration, --flags-file, --flatten, --format, --help, --impersonate-service-account, --log-http, --project, --quiet, --trace-token, --user-output-enabled, --verbosity.

Run $ gcloud help for details.

NOTES
This command is currently in alpha and might change without notice. If this command fails with API permission errors despite specifying the correct project, you might be trying to access an API with an invitation-only early access allowlist. These variants are also available:
gcloud asset export
gcloud beta asset export