01 Run compute instances describe command (Windows/macOS/Linux) using the name of the virtual machine (VM) instance that you want to reconfigure as identifier parameter (see Audit section part II to identify the right resource), to describe the configuration metadata available for the selected instance:
gcloud compute instances describe cc-production-instance
--zone us-central1-a
02 The command output should return the requested configuration information. This data will be used later to re-create the selected instance:
cpuPlatform: Intel Haswell
deletionProtection: false
disks:
- autoDelete: true
boot: true
deviceName: cc-production-instance
diskSizeGb: '100'
guestOsFeatures:
- type: VIRTIO_SCSI_MULTIQUEUE
- type: UEFI_COMPATIBLE
interface: SCSI
kind: compute#attachedDisk
mode: READ_WRITE
source: https://www.googleapis.com/compute/v1/projects/cc-web-stack-project-123123/zones/us-central1-a/disks/cc-production-instance
type: PERSISTENT
displayDevice:
enableDisplay: false
networkInterfaces:
- fingerprint: FINGERPRINT
kind: compute#networkInterface
name: nic0
network: https://www.googleapis.com/compute/v1/projects/cc-web-stack-project-123123/global/networks/cc-vpc
networkIP: 127.0.0.1
stackType: IPV4_ONLY
subnetwork: https://www.googleapis.com/compute/v1/projects/cc-web-stack-project-123123/regions/us-central1/subnetworks/cc-web-stack-network-01
...
kind: compute#instance
machineType: https://www.googleapis.com/compute/v1/projects/cc-web-stack-project-123123/zones/us-central1-a/machineTypes/n1-standard-8
name: cc-production-instance
enableIntegrityMonitoring: true
enableSecureBoot: false
enableVtpm: true
shieldedInstanceIntegrityPolicy:
updateAutoLearnPolicy: true
startRestricted: false
status: RUNNING
tags:
items:
- http-server
- https-server
zone: https://www.googleapis.com/compute/v1/projects/cc-web-stack-project-123123/zones/us-central1-a
03 Run compute images create command (Windows/macOS/Linux) to create a machine image from the Google Compute Engine instance that you want to re-create. Include the --force flag to create the image from a running instance (by default, you cannot create images from running VM instances):
gcloud compute images create cc-production-instance-image
--source-disk cc-production-instance
--source-disk-zone us-central1-a
--storage-location us-central1
--force
04 The command output should return the metadata for the newly created machine image:
Created [https://www.googleapis.com/compute/v1/projects/cc-web-stack-project-123123/global/images/cc-production-instance-image].
NAME PROJECT FAMILY DEPRECATED STATUS
cc-production-instance-image cc-web-stack-project-123123 READY
05 Run compute instances create command (Windows/macOS/Linux) using the name of the machine image created at the previous steps and the configuration details returned at step no. 2 as configuration parameters, to create a new Google Compute Engine instance from the selected image. Make sure that you avoid adding --can-ip-forward configuration parameter to the command request in order to disable IP Forwarding for the new instance:
gcloud compute instances create cc-new-production-instance
--image-project=cc-web-stack-project-123123
--image=cc-production-instance-image
--zone=us-central1-a
--machine-type=n1-standard-8
--network-interface=subnet=cc-web-stack-network-01
06 The command output should return the metadata available for the new VM instance:
Created [https://www.googleapis.com/compute/v1/projects/cc-web-stack-project-123123/zones/us-central1-a/instances/cc-new-production-instance].
NAME ZONE MACHINE_TYPE INTERNAL_IP EXTERNAL_IP STATUS
cc-new-production-instance us-central1-a n1-standard-8 10.128.0.5 xxx.xxx.xxx.xxx RUNNING
07 To avoid extra charges on your Google Cloud monthly bill, you can remove the source (non-compliant) instance from your GCP project. To remove the required instance, run compute instances delete command (Windows/macOS/Linux) using the name of the source (non-compliant) instance that you want to remove as identifier parameter, to remove the selected resource from your GCP project:
gcloud compute instances delete cc-production-instance
--zone us-central1-a
08 Press Y at the command prompt to confirm the resource removal: IMPORTANT: Deleting Google Cloud VM instances that are acting as routers/packet forwarders may break your network connectivity.
The following instances will be deleted. Any attached disks configured
to be auto-deleted will be deleted unless they are attached to any
other instances or the `--keep-disks` flag is given and specifies them
for keeping. Deleting a disk is irreversible and any data on the disk
will be lost.
- [cc-production-instance] in [us-central1-a]
Do you want to continue (Y/n)?
09 The command output should return the URL of the deleted VM instance:
Deleted [https://www.googleapis.com/compute/v1/projects/cc-web-stack-project-123123/zones/us-central1-a/instances/cc-production-instance].
10 Repeat steps no. 1 – 9 to disable IP Forwarding for other virtual machine instances available within the selected project.
11 Repeat steps no. 1 – 10 for each GCP project deployed in your Google Cloud account.