• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

google

Terraform GCP Instance

February 3, 2021

Here’s a Terraform script for launching an instance in Google Cloud Platform.

provider "google" {
  project = "project-id"
  region  = "us-central1"
  zone    = "us-central1-a"
}
resource "google_compute_instance" "wiki" {
  name         = "wiki"
  machine_type = "n2-standard-1"
  zone         = "us-central1-a"
  tags         = ["web-server"]
  labels = {
    name        = "wiki"
    environment = "development"
  }
  boot_disk {
    initialize_params {
      image = "centos-7-v20210122"
    }
  }
  network_interface {
    network = "default"
    access_config {
    }
  }
  service_account {
    email  = "service-account@email.com"
    scopes = ["cloud-platform"]
  }
}

provider "google" { project = "project-id" region = "us-central1" zone = "us-central1-a" } resource "google_compute_instance" "wiki" { name = "wiki" machine_type = "n2-standard-1" zone = "us-central1-a" tags = ["web-server"] labels = { name = "wiki" environment = "development" } boot_disk { initialize_params { image = "centos-7-v20210122" } } network_interface { network = "default" access_config { } } service_account { email = "service-account@email.com" scopes = ["cloud-platform"] } }

Here’s a few Terraform commands.

terraform init
terraform plan
terraform apply
terraform destroy

terraform init terraform plan terraform apply terraform destroy

Filed Under: Cloud Tagged With: compute, gcp, google, instance, launch, terraform

GCP Load Balancer Logging

June 21, 2020

Go to Logging > Logs Viewer to monitor a GCP Load Balancer.

resource.type="http_load_balancer" AND resource.labels.url_map_name="your-lb" AND resource.labels.project_id="your-project-id"

resource.type="http_load_balancer" AND resource.labels.url_map_name="your-lb" AND resource.labels.project_id="your-project-id"

Filed Under: Cloud Tagged With: balancer, gcp, google, load, logging

Google SDK Install on Debian or Ubuntu

January 23, 2020

Here’s the script.

echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] \
  https://packages.cloud.google.com/apt cloud-sdk main" | \
  sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
sudo apt-get install apt-transport-https ca-certificates
sudo curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | \
  sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt-get update && sudo apt-get install google-cloud-sdk

echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] \ https://packages.cloud.google.com/apt cloud-sdk main" | \ sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list sudo apt-get install apt-transport-https ca-certificates sudo curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | \ sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - sudo apt-get update && sudo apt-get install google-cloud-sdk

Filed Under: Cloud Tagged With: apt, apt-get, debian, gcloud, google, install, sdk, ubuntu

Feedburner HTTPS Feed

January 12, 2020

When Google acquired Feedburner a few years ago, we thought it would make Feedburner a better product. The opposite has happened. Google has basically shelved the Feedburner product. There hasn’t been any updates to Feedburner the last 5 years.

If you’ve recently updated your site from http to https, you may have noticed that https feeds are not supported. It looks like Google doesn’t plan on updating Feedburner anytime soon. If you want to replace Feedburner, take a look at couple of options. Try FeedBlitz or perhaps even Mailchimp.

In addition, you can import your current subscribers, and never miss a beat.

Filed Under: WP Tagged With: feed, feedblitz, feedburner, google, mailchimp, subscribers, wordpress

GCP Change Instance Type

November 18, 2019

Here’s how to change instance types via the command line

# Set Project
gcloud config set project your-project-id
 
# Change instance type to 2 CPU 20GB memory.
gcloud compute instances set-machine-type your-server-name \
--zone us-east1-a \
--machine-type n2-custom-2-20480
 
# Change instance type to original settings.
gcloud compute instances set-machine-type your-server-name \
--zone us-east1-a \
--machine-type n2-custom-2-15360

# Set Project gcloud config set project your-project-id # Change instance type to 2 CPU 20GB memory. gcloud compute instances set-machine-type your-server-name \ --zone us-east1-a \ --machine-type n2-custom-2-20480 # Change instance type to original settings. gcloud compute instances set-machine-type your-server-name \ --zone us-east1-a \ --machine-type n2-custom-2-15360

Filed Under: Cloud Tagged With: change, gcp, google, instance, type

GCP Service Accounts

September 25, 2019

Here’s how display the Service Account of a particular instance in Google Cloud.

gcloud compute instances describe server-name \
--zone us-central1-c \
--project project-id \
--format="flattened(serviceAccounts[].email)"

gcloud compute instances describe server-name \ --zone us-central1-c \ --project project-id \ --format="flattened(serviceAccounts[].email)"

Result is:

serviceAccounts[0].email: service-account-name@project-id.iam.gserviceaccount.com

serviceAccounts[0].email: service-account-name@project-id.iam.gserviceaccount.com

Filed Under: Cloud Tagged With: compute, describe, gcp, google, instances, service account

GCloud Interactive Shell

September 21, 2019

If you already have Google SDK installed, you can activate GCloud Interactive Shell, which is still in beta by the way, by typing the following command from the Google SDK terminal.

gcloud beta interactive

gcloud beta interactive

The interactive shell environment has auto-completion. It shows you who’s logged in and which project you are currently set in. To exit the interactive shell, just Press F9 to quit.

Filed Under: Cloud Tagged With: activate, beta, gcloud, gcp, google, interactive, sdk, shell

GCP Lists Disk Per Project

August 9, 2019

Here’s the Google Cloud Platform (GCP) GCloud command to list all disks in a specific project.

gcloud compute disks list --project yourprojectname

gcloud compute disks list --project yourprojectname

Filed Under: Cloud Tagged With: disks, gcloud, gcp, google, list, project

  • Go to page 1
  • Go to page 2
  • Go to Next Page »
  • Home
  • About
  • Archives

Copyright © 2023