Skip to content

Instantly share code, notes, and snippets.

@sathishphcl
sathishphcl / example-snapshot-sharing.sh
Created September 5, 2024 13:17 — forked from mikesparr/example-snapshot-sharing.sh
Example sharing snapshots across projects in different regions for disk analysis
#!/usr/bin/env bash
#####################################################
# SETUP (OPTIONAL)
#
# Note: this code is not meant to just run;
# copy and paste snippets as you go.
#####################################################
export PROJECT_ID=$(gcloud config get-value project)
@sathishphcl
sathishphcl / gcp-pro-networking-cert.md
Created September 5, 2024 12:50 — forked from mikesparr/gcp-pro-networking-cert.md
Study notes for the GCP Professional Network Engineer cert exam

GCP Professional Network Engineer

RFC1918 IP Address Allocation for Private Internets

  • determine the number of servers and IP address you need
  • determine number of private hosts first
    • 10.0.0.0/8 (24-bit; Class A)
    • 172.16.0.0/12 (20-bit; 16 Class B blocks)
    • 192.168.0.0/16 (16-bit; 256 Class C blocks)
  • use route summarization for better routing performance and management
  • 192.168.0.0/24 and 192.168.1.0/24 could be 192.168.0.0/23, spanning both (borrowing a bit)
@sathishphcl
sathishphcl / gcp-gce-snapshots-delete-restore.sh
Created September 5, 2024 12:50 — forked from mikesparr/gcp-gce-snapshots-delete-restore.sh
Experiment creating disk snapshots and deleting all but one to verify data restored for Google Cloud Platform (GCP) Compute Engine
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/compute/docs/instances/create-start-instance
# - https://cloud.google.com/compute/docs/disks/create-snapshots
# - https://cloud.google.com/compute/docs/disks/restore-snapshot
#####################################################################
export PROJECT_ID=$(gcloud config get-value project)
export PROJECT_USER=$(gcloud config get-value core/account) # set current user
@sathishphcl
sathishphcl / gcp-gce-snapshots-delete-restore.sh
Created September 5, 2024 12:50 — forked from mikesparr/gcp-gce-snapshots-delete-restore.sh
Experiment creating disk snapshots and deleting all but one to verify data restored for Google Cloud Platform (GCP) Compute Engine
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/compute/docs/instances/create-start-instance
# - https://cloud.google.com/compute/docs/disks/create-snapshots
# - https://cloud.google.com/compute/docs/disks/restore-snapshot
#####################################################################
export PROJECT_ID=$(gcloud config get-value project)
export PROJECT_USER=$(gcloud config get-value core/account) # set current user
@sathishphcl
sathishphcl / vmdk_vhdx.md
Created September 4, 2024 07:50 — forked from rahilwazir/vmdk_vhdx.md
Convert VMWare to Hyper-V (vmdk to vhdx)
@sathishphcl
sathishphcl / install.sh
Created August 29, 2024 15:26 — forked from mikesparr/install.sh
Google Cloud Platform quota monitoring solution (QMS) installation script
#!/usr/bin/env bash
APP_NAME="quota-monitoring"
SVC_ACCT_NAME="$APP_NAME-sa"
CURRENT_USER=$(gcloud config get-value core/account)
function configure() {
echo "Setting environment variables ..."
read -p "Enter base domain for org (without .com) [example]: " DOMAIN
@sathishphcl
sathishphcl / gcp-startup-script-secret-manager.sh
Created August 29, 2024 15:21 — forked from mikesparr/gcp-startup-script-secret-manager.sh
Example fetching and using Google Cloud Platform Secret Manager secrets from Compute Engine VM startup script
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/secret-manager/docs/create-secret-quickstart
# - https://cloud.google.com/secret-manager/docs/manage-access-to-secrets
# - https://cloud.google.com/secret-manager/docs/creating-and-managing-expiring-secrets
# - https://cloud.google.com/secret-manager/docs/secret-rotation
# - https://cloud.google.com/compute/docs/access/create-enable-service-accounts-for-instances
# - https://cloud.google.com/iam/docs/best-practices-service-accounts#single-purpose
@sathishphcl
sathishphcl / org-policies-gcloud-gcp.sh
Created August 29, 2024 15:21 — forked from mikesparr/org-policies-gcloud-gcp.sh
Recommended GCP Organization Policies
#####################################################################
# ORG POLICIES (SET ON DEMO PARENT FOLDER FOR DEMO [SHOULD SET ON ORG])
# REF: https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints#how-to_guides
# REF: https://cloud.google.com/storage/docs/org-policy-constraints
#####################################################################
# disable external IPs for VMs
export IP_POLICY_FILE=policy-extip.json
cat > $IP_POLICY_FILE << EOF
{
"constraint": "constraints/compute.vmExternalIpAccess",
@sathishphcl
sathishphcl / gcp-vpn-vpc-to-vpc.sh
Created August 29, 2024 15:11 — forked from mikesparr/gcp-vpn-vpc-to-vpc.sh
Example setting up Cloud VPN on Google Cloud Platform (GCP) to connect two VPCs
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/sql/docs/postgres/configure-private-ip
# - https://cloud.google.com/build/docs/private-pools/set-up-private-pool-to-use-in-vpc-network#setup-private-connection
# - https://cloud.google.com/network-connectivity/docs/vpn/how-to/creating-ha-vpn2#gcloud
# - https://cloud.google.com/network-connectivity/docs/vpn/how-to/creating-ha-vpn (optional with peering)
#####################################################################
@sathishphcl
sathishphcl / cloud-run-nat-serial.sh
Created August 29, 2024 15:07 — forked from mikesparr/cloud-run-nat-serial.sh
Experiment on Google Cloud with Cloud Run, Cloud NAT, Private Google Access, and Secure Web Proxy with NAT only for external requests
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/sdk/gcloud/reference/compute/networks/create
# - https://cloud.google.com/sdk/gcloud/reference/compute/networks/subnets/create
# - https://cloud.google.com/vpc/docs/configure-private-google-access
# - https://cloud.google.com/network-connectivity/docs/router/how-to/create-router-vpc-network#gcloud
# - https://cloud.google.com/nat/docs/set-up-manage-network-address-translation
# - https://cloud.google.com/nat/docs/using-nat-rules