AWS just added a new feature called CloudShell. It will give users who are logged in to the AWS console access to a VM where users can run AWS CLI commands. Permissions to AWS resources is based on the user’s permissions which are managed via IAM. CloudShell is similar to the cloud shells that Azure and GCP already offer. Here’s a snapshot of AWS CloudShell.
Here’s a quick script to stand up a web server based on Centos image.
gcloud compute instances create [VM-NAME] \ --zone=[ZONE] \ --image-family=debian-9 \ --image-project=debian-cloud \ --tags=allow-ssh,allow-health-check \ --subnet=lb-subnet \ --metadata=startup-script='#! /bin/bash apt-get update apt-get install apache2 -y a2ensite default-ssl a2enmod ssl vm_hostname="$(curl -H "Metadata-Flavor:Google" \ http://169.254.169.254/computeMetadata/v1/instance/name)" echo "Page served from: $vm_hostname" | \ tee /var/www/html/index.html systemctl restart apache2'
Here are the steps how to migrate a GCP VM from one network to another. It involves recreating the instance in that network.
- Find the VM. Click the ‘Create Similar’ button.
- Select the new network. Save Network. Everything else should stay the same.
- Don’t click Create, but get the ‘Create Similar’ command line script only. Click Cancel after.
- Make sure to edit the hostname. GCP appends a ‘-1’ at the end of hostname.
- Edit VM to keep all disks. Delete VM. Make sure to preserve boot drive.
- Run the ‘Create Similar’ command line script you capture to create new VM in the new network.
- The new VM will be based on golden image.
- Stop VM. Swap new disks with old disks.
- Start VM.