Skip to content

Instantly share code, notes, and snippets.

@arttuladhar
Last active April 25, 2019 02:35
Show Gist options
  • Save arttuladhar/c003977400e9f2114dc880d064e09fbd to your computer and use it in GitHub Desktop.
Save arttuladhar/c003977400e9f2114dc880d064e09fbd to your computer and use it in GitHub Desktop.

Activating Service Account

gcloud auth activate-service-account --key-file credentials.json

Copy File from Local to Cloud Stoage Bucket

gsutil cp setup.html gs://$BUCKET_NAME_1/

GET ACL (Access Control List)

gsutil acl get gs://$BUCKET_NAME_1/setup.html  > acl.txt

Rewriting File

gsutil rewrite -k gs://$BUCKET_NAME_1/setup2.html

Bucket Lifecycle

### View lifecycle for the bucket
gsutil lifecycle get gs://$BUCKET_NAME_1

### Setting Lifecycle Policy on a Bucket
gsutil lifecycle set life.json gs://$BUCKET_NAME_1

Store Bucket Versioning

### Get Versioning for a Bucket
gsutil versioning get gs://$BUCKET_NAME_1

### Set Versioning for a Bucket
gsutil versioning set on gs://$BUCKET_NAME_1

Google Storage

## View Files in Storage Bucket
gsutil cat gs://$BUCKET_NAME_2/$FILE_NAME

Create VPN

gcloud compute target-vpn-gateways \
create vpn-1 \
--network vpn-network-1  \
--region us-central1

Reserve Static IP for VPN Gateway

gcloud compute addresses create --region us-central1 vpn-1-static-ip

Extensible Service Proxy (ESP) forwarding to vpn-1

gcloud compute \
forwarding-rules create vpn-1-esp \
--region us-central1  \
--ip-protocol ESP  \
--address $STATIC_IP_VPN_1 \
--target-vpn-gateway vpn-1

Creating VPN Tunnel from Network 1 to Network 2

gcloud compute \
vpn-tunnels create tunnel1to2  \
--peer-address $STATIC_IP_VPN_2 \
--region us-central1 \
--ike-version 2 \
--shared-secret gcprocks \
--target-vpn-gateway vpn-1 \
--local-traffic-selector 0.0.0.0/0 \
--remote-traffic-selector 0.0.0.0/0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment