Question

Difficulty: EasyDeploying and Configuring Cloud Storage Buckets and Objects

An administrator needs to deploy a Cloud Storage bucket for log archiving and configure a lifecycle management policy using the Google Cloud CLI (`gcloud storage`). Place the following steps in the correct execution order from first to last.

  1. 1Draft a local JSON file specifying the lifecycle conditions and actions (such as transitioning objects to Nearline storage after 30 days).
  2. 2Execute `gcloud storage buckets create gs://my-log-archive-bucket --location=us-central1` to provision the destination bucket.
  3. 3Execute `gcloud storage buckets update gs://my-log-archive-bucket --lifecycle-file=lifecycle.json` to attach the policy.
  4. 4Upload the log files into the bucket using `gcloud storage cp log.txt gs://my-log-archive-bucket/`.

Answer

The correct operational sequence is: 1) Create the local lifecycle JSON file, 2) Provision the Cloud Storage bucket with `gcloud storage buckets create`, 3) Apply the lifecycle configuration to the bucket using `gcloud storage buckets update`, and 4) Upload objects to the configured bucket using `gcloud storage cp`.
Deploying a configured storage bucket requires creating the prerequisite configuration files, provisioning the bucket resource via CLI, binding the lifecycle rules file to the bucket resource, and finally populating the bucket with objects.

Step-by-Step Solution

1
Define lifecycle policy rules locally in a JSON file.
A valid `lifecycle.json` file is prepared with specified actions and conditions.
Lifecycle updates using the CLI require a reference file containing the policy definition.
2
Create the bucket resource.
The bucket `gs://my-log-archive-bucket` is instantiated in `us-central1`.
Configurations cannot be applied to a non-existent bucket.
3
Apply the lifecycle JSON policy to the newly deployed bucket.
The bucket lifecycle configuration is set.
Attaching the policy before object ingestion ensures incoming files immediately fall under lifecycle management.
4
Copy target objects into the Cloud Storage bucket.
Objects are stored in the bucket and subject to the configured lifecycle rules.
Data upload occurs after infrastructure provisioning and rule binding.

Key Concept

Cloud Storage Bucket Provisioning and Lifecycle Rule Configuration
Rate this question