Skip to content

Instantly share code, notes, and snippets.

@mieitza
mieitza / gcp-start-iap-tunnel-ssh-proxy-magic.sh
Created May 16, 2023 15:28 — forked from netj/gcp-start-iap-tunnel-ssh-proxy-magic.sh
a nifty script for accessing with native SSH your IAP allowed Compute Engine instances
#!/usr/bin/env bash
# ~/.ssh/gcp-start-iap-tunnel-ssh-proxy-magic.sh
# a script to be used as SSH ProxyCommand to allow fully functional SSH access to any Google Cloud Compute Engine VMs allowing IAP access
#
# Author: Jaeho Shin <[email protected]>
# Created: 2022-10-31
# See also:
# - https://gist.github.com/netj/df4f9de1fefd254ab11979be7035b5d0/#readme
# - https://cloud.google.com/iap/docs/using-tcp-forwarding
#
@mieitza
mieitza / GCP_Console.sh
Created May 16, 2023 15:16 — forked from bluemyria/GCP_Console.sh
GCP Dev: 1. DevEnv - Python
# Navigation menu => Compute Engine => VM Instances => Create
# Identity and API access => Allow full access to all Cloud APIs.
# Firewall => Allow HTTP traffic
# SSH
sudo apt-get update
sudo apt-get install git
sudo apt-get install python-setuptools python-dev build-essential
sudo easy_install pip
@mieitza
mieitza / 1_quiz_gcp_datastore.py
Created May 16, 2023 15:15 — forked from bluemyria/1_quiz_gcp_datastore.py
GCP Dev: 2. Storing Application Data in Cloud Datastore - Python
# Import the os module
import os
# Use the os module to get the GCLOUD_PROJECT environment variable
project_id = os.getenv('GCLOUD_PROJECT')
from flask import current_app
# Import the datastore module from the google.cloud package.
from google.cloud import datastore
@mieitza
mieitza / 1_quiz_gcp_storage.py
Created May 16, 2023 15:15 — forked from bluemyria/1_quiz_gcp_storage.py
CGP Dev 3. Storing Image/Video Files in Cloud Storage - Python
# Get the Bucket name from the GCLOUD_BUCKET environment variable
bucket_name = os.getenv('GCLOUD_BUCKET')
# Import the storage module
from google.cloud import storage
# Create a client for Cloud Storage
storage_client = storage.Client()
# Use the client to get the Cloud Storage bucket
@mieitza
mieitza / 1_GCP_Console.sh
Created May 16, 2023 15:15 — forked from bluemyria/1_GCP_Console.sh
CGP Dev 4. Adding User Authentication - Python
git clone https://github.com/GoogleCloudPlatform/training-data-analyst
cd ~/training-data-analyst/courses/developingapps/python/firebase/start
. prepare_environment.sh
python run_server.py
# Web preview > Preview on port 8080 to preview the Quiz application.
# Note Cloud Shell Web preview domain (in form: 8080-dot-2958229-dot-devshell.appspot.com)
# Create a Firebase project
# Develop > Authentication > Set up sign-in method > Email/Password > Enable
# Under Authorized Domains > Add Domain (in form: 8080-dot-2958229-dot-devshell.appspot.com)
@mieitza
mieitza / GCP_Console.sh
Created May 16, 2023 15:14 — forked from bluemyria/GCP_Console.sh
CGP Dev 5. Developing a Backend Service - Python
# Create a Cloud Pub/Sub topic
# In the Cloud Platform Console, click Navigation menu > Pub/Sub > Topics.
# Create a topic., eg "feedback"
gcloud pubsub subscriptions create worker-subscription --topic feedback
#Publish a message to a Cloud Pub/Sub topic
gcloud pubsub topics publish feedback --message "Hello World"
#Retrieve a message from a Cloud Pub/Sub subscription
@mieitza
mieitza / gcp-basics.md
Created May 16, 2023 14:57 — forked from michaellihs/gcp-basics.md
Google Cloud Platform

Google Cloud Platform Fundamentals

Regions & Zones

  • Region equals a geograpic location
  • Zones divide regions into (physically) independent isolated sub parts
  • Some resources are
  • accessible only within one zone (e.g. VMs)
@mieitza
mieitza / gcp_guide.md
Created May 16, 2023 14:55 — forked from nicolasdao/gcp_guide.md
Google Cloud Platform guide. Keywords: gcp google cloud platform gcloud
@mieitza
mieitza / gcp-startup-script-secret-manager.sh
Created May 16, 2023 14:35 — 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