0
0
GCPcloud~5 mins

What is Google Cloud Platform in GCP - CLI Guide

Choose your learning style9 modes available
Introduction
Google Cloud Platform is a set of online tools and services that help you run websites, store data, and build apps without needing your own servers. It solves the problem of managing physical computers by letting you use Google's powerful computers over the internet.
When you want to host a website without buying and managing your own server.
When you need to store large amounts of data safely and access it from anywhere.
When you want to run applications that can grow or shrink automatically based on demand.
When you want to analyze data quickly using powerful tools without setting up hardware.
When you want to build and test software in a shared environment with easy access to resources.
Commands
This command lets you sign in to your Google Cloud account so you can use its services from the command line.
Terminal
gcloud auth login
Expected OutputExpected
Your browser has been opened to visit: https://accounts.google.com/o/oauth2/auth?... You are now logged in as [user@example.com].
This sets the current project where your Google Cloud resources will be created and managed.
Terminal
gcloud config set project my-sample-project
Expected OutputExpected
Updated property [core/project].
This creates a virtual machine named example-vm in the specified zone to run your applications or services.
Terminal
gcloud compute instances create example-vm --zone=us-central1-a
Expected OutputExpected
Created [https://www.googleapis.com/compute/v1/projects/my-sample-project/zones/us-central1-a/instances/example-vm]. NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS example-vm us-central1-a e2-medium 10.128.0.2 34.68.194.64 RUNNING
--zone - Specifies the location where the virtual machine will be created.
This lists all the virtual machines you have running in your current project.
Terminal
gcloud compute instances list
Expected OutputExpected
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS example-vm us-central1-a e2-medium 10.128.0.2 34.68.194.64 RUNNING
Key Concept

If you remember nothing else, remember: Google Cloud Platform lets you use powerful computers and services over the internet so you don't need your own hardware.

Common Mistakes
Not logging in with 'gcloud auth login' before running other commands.
Without logging in, the commands won't know which account to use and will fail.
Always run 'gcloud auth login' first to sign in to your Google Cloud account.
Forgetting to set the project with 'gcloud config set project' before creating resources.
Google Cloud needs to know which project to place your resources in; otherwise, commands will fail or use the wrong project.
Set your project explicitly using 'gcloud config set project your-project-id' before creating resources.
Summary
Use 'gcloud auth login' to sign in to your Google Cloud account.
Set your working project with 'gcloud config set project'.
Create virtual machines with 'gcloud compute instances create' to run your apps.
List your running virtual machines with 'gcloud compute instances list' to check their status.