Question

Difficulty: MediumDeploying and Configuring Cloud Storage Buckets and Objects

A solutions developer needs to upload a large database export named `db_archive.tar.gz` to an existing Google Cloud Storage bucket named `corp-database-backups`. The bucket currently uses the Standard storage class by default for newly uploaded objects. However, to minimize immediate storage costs for this specific file, the developer must ensure that `db_archive.tar.gz` is assigned the Coldline storage class directly during the upload process, without changing the default storage class configuration of the bucket itself. Which Google Cloud CLI command should the developer execute to achieve this?

  1. A
    gcloud storage buckets update gs://corp-database-backups --default-storage-class=COLDLINE
  2. gcloud storage cp db_archive.tar.gz gs://corp-database-backups/ --storage-class=COLDLINEAnswer
  3. C
    gsutil cp --default-storage-class=COLDLINE db_archive.tar.gz gs://corp-database-backups/
  4. D
    gcloud storage objects update gs://corp-database-backups/db_archive.tar.gz --storage-class=COLDLINE

Answer

Execute the command: gcloud storage cp db_archive.tar.gz gs://corp-database-backups/ --storage-class=COLDLINE
The correct command uses `gcloud storage cp` accompanied by the `--storage-class=COLDLINE` parameter. This uploads the specific file to the target Google Cloud Storage bucket and assigns it the Coldline storage class upon creation, leaving the bucket's default storage class setting untouched for other uploads.

Step-by-Step Solution

1
Identify the required CLI tool and operation type
Google Cloud CLI (`gcloud storage`) is standard for object copying and upload operations.
Uploading a file from local storage to a Cloud Storage URI requires an object copy (`cp`) operation.
2
Determine how to apply per-object storage class during upload
Use the `--storage-class=COLDLINE` flag on the `gcloud storage cp` command.
Passing `--storage-class` during the upload overrides the bucket default specifically for the object being uploaded.
3
Verify bucket default settings remain intact
No bucket update command (`gcloud storage buckets update`) is executed.
Updating bucket properties would affect all future uploads, which violates the requirement to preserve the bucket's existing default storage class.

Key Concept

Per-Object Storage Class Specification during Upload using gcloud storage CLI
Rate this question