Last active
March 15, 2025 15:54
-
-
Save kamarton/aa80eb06b4b931c7edfb7124f103a503 to your computer and use it in GitHub Desktop.
Create disk from snapshot attach to compute engine and start it (GCP, CLI, GCLOUD)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
PROJECT=<project> | |
ZONE=<zone> | |
INSTANCE=<compute-engine-instance> | |
DISK=<disk-name> | |
SNAPSHOT=<snapshot-name> | |
REGION=<region> | |
echo create disk from snapshot - - - - - - - - - - - - - - - | |
gcloud compute disks create $DISK \ | |
--source-snapshot $SNAPSHOT \ | |
--zone $ZONE \ | |
--type pd-ssd \ # disk type | |
--project=$PROJECT | |
echo attach to vm - - - - - - - - - - - - - - - - - - - - - - | |
gcloud compute instances attach-disk $INSTANCE \ | |
--disk $DISK --boot \ | |
--project=$PROJECT \ | |
--zone $ZONE | |
echo start vm - - - - - - - - - - - - - - - - - - - - - - | |
gcloud compute instances start $INSTANCE \ | |
--zone $ZONE \ | |
--project=$PROJECT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment