Skip to content
/ GCP Public

This repo is dedicated to becoming familiar with the basics of Google Cloud Shell.

Notifications You must be signed in to change notification settings

kjzamora/GCP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

GCP

Table of Contents

Table of contents generated with markdown-toc




Setting gcloud CLI Environment and Variables

To define a variable named "MY_VARIABLE" within gcloud CLI:

export MY_VARIABLE=<your_VARIABLE>

To verify that variable was set:

echo $MY_VARIABLE

To define the zone your instances will reside in:

gcloud config set compute/zone $ZONE

To define the region:

gcloud config set compute/region $REGION



Creating a Single Instance

The following command assumes you have a zone defined in the gcloud CLI:

gcloud compute instances create $INSTANCE_NAME --machine-type $MACHINE_TYPE --image-family $IMAGE

If you would like to run a set of commands to say install something as soon as the instance is running you can add a startup script:

gcloud compute instances create $INSTANCE_NAME --machine-type $MACHINE_TYPE --image-family $IMAGE --metadata-from-file startup-script=startup.sh



Buckets

Creating a Bucket:

A bucket must have a globally unique name. A simple way is to define the bucket name is basing it off your Project ID which must also be globally unqiue:

export BUCKET=<project_id-bucket_name>
gsutil mb -p $PROJECT gs://$BUCKET

Upload to a Bucket:

From the cloud shell:

gsutil cp $FILENAME gs://$BUCKET

Delete from a Bucket:

From the cloud shell:

gsutil rm gs://$BUCKET/$FILENAME

Copy from one folder to another within a Bucket:

From the cloud shell:

gsutil cp gs://$BUCKET/$FILENAME gs://$BUCKET/$FOLDER_NAME/

List Contents of the Bucket:

From the cloud shell:

gsutil ls gs://$BUCKET

Make an Object in your Bucket Public:

From the cloud shell:

gsutil acl ch -u AllUsers:R gs://$BUCKET/$FILENAME

Remove Access from an Object in your Bucket:

From the cloud shell:

gsutil acl ch -d AllUsers gs://$BUCKET/$FILENAME

About

This repo is dedicated to becoming familiar with the basics of Google Cloud Shell.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published