IAM
-
Member
-
Google account (for end users)
-
service account
(for apps and VMs)-
Create a
Service Account
gcloud iam service-accounts create <SERVICE_ACCOUNT_NAME> --display-name '<DISPLAY_NAME>'
-
Service accounts
are equivalent toAWS IAM Roles
.
-
-
Format
user|group|serviceAccount:<EMAIL_ADDRESS>
domain:<DOMAIN>
-
-
-
Basic roles (opens in a new tab)
- Owner
- Editor
- Viewer
-
Predefined roles (opens in a new tab)
-
Listing
predefined roles
gcloud iam roles list
-
-
Custom roles (opens in a new tab)
-
Custom roles
enable you to enforce theprinciple of least privilege
, ensuring that the user and service accounts in yourorganization
have only the permissions essential to performing their intended functions. -
Custom roles
can only be used to grant permissions in policies for the sameproject
ororganization
that owns theroles
orresources
under them. You cannot grantcustom roles
from oneproject
ororganization
on aresource
owned by a differentproject
ororganization
. -
To create a
custom role
, a caller must have theiam.roles.create
permission. By default, theowner
of aproject
or anorganization
has thispermission
and can create and managecustom roles
. -
Listing the
custom roles
on project levelgcloud iam roles list --project <PROJECT_ID>
-
Updating a
custom role
using aYAML
file- Output
role
metadata inYAML
format bygcloud iam roles describe <ROLE_NAME>
- Edit the outputted
YAML
file and change the content as desired - Update the role by
gcloud iam roles update <ROLE_ID> --project <PROJECT_ID> --file <YAML-file>
- Output
-
Disabling a
custom role
When a
role
is disabled, any policy bindings related to therole
areinactivated
, meaning that thepermissions
in the role will not be granted, even if you grant therole
to auser
.gcloud iam roles update viewer --project <PROJECT_ID> --stage DISABLED
-
-
If a
role
is beingphased out
, change itsrole.stage
property toDEPRECATED
, and set thedeprecation_message
to let users know what alternative roles should be used or where to get more information.
-
-
-
Viewing the available
permissions
for aresource
gcloud iam list-testable-permissions //cloudresourcemanager.googleapis.com/projects/<PROJECT_ID>
-
Getting the
role
metadata, includingpermissions
particularlygcloud iam roles describe <ROLE_NAME>
-
Viewing the grantable
roles
onresources
gcloud iam list-grantable-roles //cloudresourcemanager.googleapis.com/projects/<PROJECT_ID>
-
-
Permissions
(opens in a new tab)- Permission form:
<service>.<resource>.<verb>
Permissions
usually, but not always, correspond1:1
withREST
methods.
- Permission form:
-
Policy Binding
-
A
policy binding
is useful only if you add it to aresource
. -
Add a policy binding to a resource
gcloud <RESOURCE_TYPE> add-iam-policy-binding <RESOURCE_NAME> --member=<MEMBER> --role=roles/<ROLE_NAME>
-
Config
-
CLI
-
get the current
project ID
gcloud config get-value project
-
change the current
project
gcloud config set project <project-ID>
-
get the list of all
projects
gcloud projects list
gcloud config list project
-
list available Regions and Zones
gcloud compute regions list
gcloud compute zones list
-
list all properties and settings
gcloud config list --all
-
Storage
Product | Simple Description | Ideal for | Not Ideal for | R/W Latency | Typical Size | Storage Type |
---|---|---|---|---|---|---|
Cloud Storage | Binary/object store | Large or rarely accessed unstructured data | Structured data, building fast apps | Medium (100s of ms) | Any | Object |
Datastore | Scalable store for structured serve | GAE apps, structured pure-serve use cases | Relational or analytic data | Medium (10s of ms) | < 200 TB | Document |
Bigtable | High-volume, low-latency database | "Flat" heavy read/write, or analytical data | High structure or transactional data | Low (ms) | 2 TB - 10 PB | Key-Value |
Cloud SQL | Well-understood VM-based RDBMS | Web frameworks, exisitng applications | Scaling, analytics, heavy writes | Low (ms) | < 10 TB | Relational |
Spanner | Relational DB service | Low-latency transactional systems | Analytic data | Low (ms) | Any | Relational |
BigQuery | Auto-scaling analytic data warehouse | Interactive analysis of static datasets | Building fast apps | High(s) | Any | Columnar |
App Engine
-
Services
Services
onApp Engine
provide a way to split your application into smaller, more manageable pieces. Similar tomicroservices
,App Engine
services
act as independent components of computing. -
Delete
application
There's no direct way to delete the
application
onApp Engine
. There are 2 alternatives:- Disable the
application
inApp Engine
settings - Delete the whole
project
- Disable the
-
Java
-
Java 11 runtime (opens in a new tab)
- Doesn't include any web framework, therefore not limited to
Java Servlet
. - Uses
JAR
instead ofWAR
- Doesn't support
App Engine Java SDK
- Doesn't include any web framework, therefore not limited to
-
Load Balancing
Cloud Storage
-
Copy all contents under a folder including all subfolders recursively
gsutil cp -r <SOURCE_URL> <TARGET_URL>
Cloud Build
-
Create a
Docker
repository inArtifact Registry
gcloud artifacts repositories create <repo-name> --repository-format=docker --location=us-central1 --description="<description>"
-
List all repos created in the current project
gcloud artifacts repositories list
-
Build and push an image to the repo
gcloud builds submit --tag gcr.io/$GOOGLE_CLOUD_PROJECT/lab-report-service
-
Configuration (opens in a new tab)
cloudbuild.yaml
-
Cloud builders (opens in a new tab)
Cloud builders
arecontainer images
with common languages and tools installed in them.
-
CLI
-
deploy
--source
must be specified if different from last time
-
Cloud Function
-
Traits
- Not for serving highly concurrent workloads
- No support for
traffic splitting
orrevision rollback
- One
HTTP
endpoint only - One container exclusively to handle a single request
-
Types
- HTTP functions
- Event-driven functions
- Background functions
- CloudEvent functions
-
Runtimes
-
Nodejs
- Entry point file
index.js
function.js
- Entry point file
-
Python
- Entry point file
main.py
- Entry point file
-
-
Use cases
Use Case Description Data Processing / ETL
Listen and respond to Cloud Storage
events such as when a file is created, changed, or removed. Process images, perform video transcoding, validate and transform data, and invoke any service on the Internet from yourCloud Function
.Webhooks Via a simple HTTP
trigger, respond to events originating from 3rd party systems likeGitHub
,Slack
,Stripe
, or from anywhere that can sendHTTP
requests.Lightweight APIs
Compose applications from lightweight, loosely coupled bits of logic that are quick to build and that scale instantly. Your functions can be event-driven or invoked directly over HTTP/S
.Mobile Backend Use Google
's mobile platform for app developers,Firebase
, and write your mobile backend inCloud Functions
. Listen and respond to events fromFirebase Analytics
,Realtime Database
,Authentication
, andStorage
.IoT
Imagine tens or hundreds of thousands of devices streaming data into Cloud Pub/Sub
, thereby launchingCloud Functions
to process, transform and store data.Cloud Functions
lets you do in a way that's completely serverless. -
CLI
-
Check the function logs
gcloud functions logs read <function-name>
-
Cloud Run
-
The container can be invoked on an
HTTPS
endpoint. -
Automatic scaling
-
Cloud Run
will throttle theCPU
of containers that are not handling requests. -
Cloud Run
treats each deployment as a newRevision
which will first be brought online, then have traffic redirected to it. -
By default the latest
revision
will be assigned100%
of the inbound traffic for a service. -
Deployment platform
- Managed
Cloud Run
Cloud Run
onGKE
- Managed
-
List running services
gcloud run services list
-
Obtain details about a given service in
YAML
formatgcloud run services describe <SERVICE-NAME> --format=yaml
-
Obtain details about a given service with a
JSON
pathgcloud run services describe <SERVICE-NAME> --format="value(status.address.url)"
-
Deploy a container (opens in a new tab)
gcloud run deploy <CONTAINER_NAME> --image=gcr.io/<IMAGE>:<TAG>
GKE
-
List clusters
gcloud container clusters list
-
Generate
kubeconfig
for a specifiedcluster
gcloud container clusters get-credentials <CLUSTER_NAME> --zone <ZONE>
-
Cluster administration
-
Cluster resizing (opens in a new tab)
-
Increasing
- Existing Pods are not moved onto the new instances.
-
Decreasing
- The Pods that are scheduled on the instances being removed are killed.
- Pods managed by a replication controller are rescheduled by the controller onto the remaining instances
- Pods not managed by a replication controller are not restarted
- Instances are picked for removal at random.
-
-
Container Registry
-
HOSTNAME
is 1 of 4 locations:gcr.io
,us.gcr.io
,eu.gcr.io
, orasia.gcr.io
-
These locations correspond to the
multi-regions
forCloud Storage
storagebuckets
. When you push animage
to aregistry
with a newhostname
,Container Registry
creates a storagebucket
in the specifiedmulti-region
. Thisbucket
is the underlying storage for theregistry
. Within aproject
, allregistries
with the samehostname
share one storagebucket
. -
Tag the
local image
with theregistry name
, so it can be pushed to theregistry
docker tag <SOURCE_IMAGE> <HOSTNAME>/<PROJECT-ID>/<IMAGE>
-
Push the
tagged image
toContainer Registry
docker push <HOSTNAME>/<PROJECT-ID>/<IMAGE>:<TAG>
-
View the
image
you pushedgcloud container images list-tags <HOSTNAME>/<PROJECT-ID>/<IMAGE>
Cloud Shell
-
Cloud Shell
provisions5 GB
of free persistent disk storage mounted as your$HOME
directory on theVM
instance. This storage is on a per-user basis and is available acrossprojects
. -
If you do not access
Cloud Shell
regularly, the$HOME
directory persistent storage may be recycled. You will receive an email notification before this occurs. Starting aCloud Shell
session will prevent its removal. -
Accessing
Cloud Shell
from the command line (opens in a new tab)-
Establishing an interactive
SSH
session withCloud Shell
from local machinegcloud cloud-shell ssh
-
Copy a file from
Cloud Shell
to local machine (working directory of the terminal):gcloud cloud-shell scp cloudshell:~/data.txt localhost:data.txt
-
SDK
-
SDK components (opens in a new tab)
-
List SDK components
gcloud components list
-
Resources
- Google Cloud Platform blog (opens in a new tab)
- GCP - customers and case studies (opens in a new tab)
- GCP - CLI Reference (opens in a new tab)
- gcloud supplementary help (opens in a new tab)
Big Data
- GCP big data product list (opens in a new tab)
- BigQuery standard SQL guide (opens in a new tab)
- Migrating On-Premises Hadoop Infrastructure to Google Cloud (opens in a new tab)
- Cloud Blog - Databases (opens in a new tab)
- Cloud Blog - Dataproc (opens in a new tab)
- Get started with Google-provided templates (opens in a new tab)
- Connecting BigQuery and Google Sheets to help with hefty data analysis (opens in a new tab)
- Scheduling queries (opens in a new tab)
- Creating a k-means clustering model (opens in a new tab)