• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

gcp

GCP Regional Quotas

March 8, 2022

Here’s how to get Regional Quotas for your project in GCP.

gcloud compute regions describe us-central1 --project your-project-id

gcloud compute regions describe us-central1 --project your-project-id

Filed Under: Cloud Tagged With: gcloud, gcp, project, quotas, regional

GCP Monitor Service Account

February 24, 2022

You can monitor the success or failure of a service account in GCP.

gcloud policy-intelligence query-activity \
--activity-type=ACTIVITY_TYPE \ 
--project=PROJECT_ID \
--limit=LIMIT

gcloud policy-intelligence query-activity \ --activity-type=ACTIVITY_TYPE \ --project=PROJECT_ID \ --limit=LIMIT

The two options you can use for ACTIVITY_TYPE are:

  • serviceAccountKeyLastAuthentication
  • serviceAccountLastAuthentication

Filed Under: Cloud Tagged With: gcp, keys, monitor, service account

GCP Windows Password Reset

February 14, 2022

Instead of the GCP Console, you can reset Windows Server password via gcloud.

gcloud compute reset-windows-password server-name \
--zone us-central1-a \
--project project-id

gcloud compute reset-windows-password server-name \ --zone us-central1-a \ --project project-id

Username and password will generated.

Filed Under: Cloud Tagged With: gcloud, gcp, password, reset, windows

Google SDK SSH Mac Terminal

February 14, 2022

I’m having trouble logging in using Google SDK Compute SSH on a Mac Terminal.

Here’s the fix.

gcloud compute ssh USERNAME@SERVER --zone ZONE --project PROJECTID --internal-ip 2>&1

gcloud compute ssh USERNAME@SERVER --zone ZONE --project PROJECTID --internal-ip 2>&1

There was an issue with a redirect to another shell.

Filed Under: Cloud, Linux Tagged With: compute, gcp, mac, redirect, sdk, ssh, terminal

GCP Reset Windows Password

February 4, 2022

How to reset password of a GCP Compute Engine running on Windows OS.

gcloud compute reset-windows-password servername \
--zone us-central1-a \
--project your-project-id

gcloud compute reset-windows-password servername \ --zone us-central1-a \ --project your-project-id

Output

This command creates an account and sets an initial password for the
user [firstname_lastname] if the account does not already exist.
If the account already exists, resetting the password can cause the
LOSS OF ENCRYPTED DATA secured with the current password, including
files and stored passwords.
 
For more information, see:
https://cloud.google.com/compute/docs/operating-systems/windows#reset
 
Would you like to set or reset the password for [firstname_lastname]
(Y/n)?  y
 
Resetting and retrieving password for [firstname_lastname] on [servername]
Updated [https://www.googleapis.com/compute/v1/projects/your-project-id/zones/us-central1-a/instances/servername].
WARNING: Instance [servername] does not appear to have an external IP
address, so it will not be able to accept external connections.
To add an external IP address to the instance, use
gcloud compute instances add-access-config.
password: xxxxxxxxxxxxxxx
username: firstname_lastname

This command creates an account and sets an initial password for the user [firstname_lastname] if the account does not already exist. If the account already exists, resetting the password can cause the LOSS OF ENCRYPTED DATA secured with the current password, including files and stored passwords. For more information, see: https://cloud.google.com/compute/docs/operating-systems/windows#reset Would you like to set or reset the password for [firstname_lastname] (Y/n)? y Resetting and retrieving password for [firstname_lastname] on [servername] Updated [https://www.googleapis.com/compute/v1/projects/your-project-id/zones/us-central1-a/instances/servername]. WARNING: Instance [servername] does not appear to have an external IP address, so it will not be able to accept external connections. To add an external IP address to the instance, use gcloud compute instances add-access-config. password: xxxxxxxxxxxxxxx username: firstname_lastname

Filed Under: Cloud Tagged With: compute, gcp, password, reset, set, windows

GCP Terraform Second Drive

February 4, 2022

How to add a second drive on GCP Compute Engine using Terraform.

provider "google" {
  project = "your-project-id"
  zone    = "us-central1-c"
}
 
resource "google_compute_disk" "data-drive" {
  name = "data-drive"
  type = "pd-standard"
  zone = "us-central1-c"
  size = "20"
}
 
resource "google_compute_attached_disk" "attach-data-drive" {
  count    = 1
  disk     = google_compute_disk.data-drive.id
  instance = google_compute_instance.test.id
}
 
resource "google_compute_instance" "test" {
  name         = "test"
  machine_type = "e2-micro"
 
  boot_disk {
    initialize_params {
      image = "rocky-linux-cloud/rocky-linux-8"
    }
  }
 
  scheduling {
    preemptible       = true
    automatic_restart = false
  }
  network_interface {
    network = "default"
    access_config {
    }
  }
}

provider "google" { project = "your-project-id" zone = "us-central1-c" } resource "google_compute_disk" "data-drive" { name = "data-drive" type = "pd-standard" zone = "us-central1-c" size = "20" } resource "google_compute_attached_disk" "attach-data-drive" { count = 1 disk = google_compute_disk.data-drive.id instance = google_compute_instance.test.id } resource "google_compute_instance" "test" { name = "test" machine_type = "e2-micro" boot_disk { initialize_params { image = "rocky-linux-cloud/rocky-linux-8" } } scheduling { preemptible = true automatic_restart = false } network_interface { network = "default" access_config { } } }

Filed Under: Cloud Tagged With: compute, drive, gcp, second, terraform, vm

GCP Create Scheduled Snapshots

February 2, 2022

How to create scheduled snapshots in GCP.

gcloud compute resource-policies create snapshot-schedule hourly \
--description "my hourly schedule" \
--max-retention-days 7 \
--start-time 00:00 \
--hourly-schedule 1 \
--region us-central1 \
--on-source-disk-delete keep-auto-snapshots \
--storage-location US

gcloud compute resource-policies create snapshot-schedule hourly \ --description "my hourly schedule" \ --max-retention-days 7 \ --start-time 00:00 \ --hourly-schedule 1 \ --region us-central1 \ --on-source-disk-delete keep-auto-snapshots \ --storage-location US

Add snapshot schedule to a disk.

gcloud compute disks add-resource-policies disk-name \
--resource-policies hourly \
--zone us-central1-a

gcloud compute disks add-resource-policies disk-name \ --resource-policies hourly \ --zone us-central1-a

gcloud compute disks create disk-name \
--resource-policies hourly \
--zone us-central1-a

gcloud compute disks create disk-name \ --resource-policies hourly \ --zone us-central1-a

List snapshot schedules.

gcloud compute resource-policies list

gcloud compute resource-policies list

Describe snapshot schedule.

gcloud compute resource-policies describe hourly

gcloud compute resource-policies describe hourly

Filed Under: Cloud Tagged With: add, create, gcp, list, schedule, snapshot

GCP Compute add startup-script to metadata

February 2, 2022

How to add a startup-script to metadata. The script executes every time VM is started.

gcloud compute instances add-metadata instance-name \
--project your-project-id \
--zone us-central1-c \
--metadata=startup-script='#! /bin/bash
sudo -i
echo "Time: $(date)" >> /tmp/date.txt'

gcloud compute instances add-metadata instance-name \ --project your-project-id \ --zone us-central1-c \ --metadata=startup-script='#! /bin/bash sudo -i echo "Time: $(date)" >> /tmp/date.txt'

Filed Under: Cloud Tagged With: add, boot, compute, gcp, metadata, startup-script

  • « Go to Previous Page
  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to page 4
  • Go to page 5
  • Interim pages omitted …
  • Go to page 16
  • Go to Next Page »
  • Home
  • About
  • Archives

Copyright © 2023