A cloud administrator needs to securely provision a Compute Engine virtual machine instance that uses a Customer-Managed Encryption Key (CMEK) for its boot disk and runs a startup script retrieved from a private Cloud Storage bucket. In what sequence should the administrator execute the administrative tasks to ensure successful VM provisioning and execution under least privilege?
- 1Grant the Compute Engine Service Agent role 'roles/cloudkms.cryptoKeyEncrypterDecrypter' on the targeted Cloud KMS key.
- 2Create a custom IAM service account and grant it 'roles/storage.objectViewer' on the Cloud Storage bucket containing the startup script.
- 3Upload the initialization script to the private Cloud Storage bucket.
- 4Run 'gcloud compute instances create' specifying '--kms-key', '--service-account', '--scopes=cloud-platform', and '--metadata=startup-script-url'.
- 5Inspect the serial port console output of the VM instance to verify successful execution of the startup script.
Answer
The correct deployment sequence is: 1) Grant the Compute Engine Service Agent the Cloud KMS Encrypter/Decrypter role. 2) Create a custom service account and assign Storage Object Viewer access to the bucket. 3) Upload the script to the private Cloud Storage bucket. 4) Run 'gcloud compute instances create' passing the CMEK key, custom service account, cloud-platform scope, and metadata URL. 5) Inspect serial port output to verify startup script completion.
The proper administrative workflow follows a logical dependency chain: Infrastructure access permissions must be granted to the service agent for CMEK disk creation first. Next, identity and access for the application payload must be established by creating a dedicated service account and granting storage read access. The payload (startup script) is then uploaded to Cloud Storage. Once prerequisites are in place, the VM instance is created with gcloud referencing the KMS key, service account, and metadata URL. Finally, serial console logs are reviewed to confirm startup script execution.
Step-by-Step Solution
Key Concept
Compute Engine CMEK disk encryption and secure startup script provisioning sequence