forked from lavishsheth/code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Google Cloud Fundamentals: Getting Started with Cloud Storage and Cloud SQL
19 lines (16 loc) · 2.04 KB
/
Google Cloud Fundamentals: Getting Started with Cloud Storage and Cloud SQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#---------------CHANGE ZONE------------------
ZONE=
REGION=${ZONE::-2}
PROJECT_ID=$GOOGLE_CLOUD_PROJECT
PROJECT_NUMBER=$(gcloud projects list --filter="qwiklabs-gcp" --format='value(PROJECT_NUMBER)')
gcloud compute instances create bloghost --project=$PROJECT_ID --zone=$ZONE --machine-type=e2-medium --network-interface=network-tier=PREMIUM,stack-type=IPV4_ONLY,subnet=default --metadata=startup-script=apt-get\ update$'\n'apt-get\ install\ apache2\ php\ php-mysql\ -y$'\n'service\ apache2\ restart,enable-oslogin=true --maintenance-policy=MIGRATE --provisioning-model=STANDARD --service-account=$PROJECT_NUMBER-compute@developer.gserviceaccount.com --scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/trace.append --tags=http-server --create-disk=auto-delete=yes,boot=yes,device-name=bloghost,image=projects/debian-cloud/global/images/debian-11-bullseye-v20231212,mode=rw,size=10,type=projects/$PROJECT_ID/zones/$ZONE/diskTypes/pd-balanced --no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring --labels=goog-ec-src=vm_add-gcloud --reservation-affinity=any
VM_IP=$(gcloud compute instances describe bloghost --zone=$ZONE --format='get(networkInterfaces[0].accessConfigs[0].natIP)')/32
export LOCATION=US
gcloud storage buckets create -l $LOCATION gs://$DEVSHELL_PROJECT_ID
gcloud storage cp gs://cloud-training/gcpfci/my-excellent-blog.png my-excellent-blog.png
gcloud storage cp my-excellent-blog.png gs://$DEVSHELL_PROJECT_ID/my-excellent-blog.png
gsutil acl ch -u allUsers:R gs://$DEVSHELL_PROJECT_ID/my-excellent-blog.png
gcloud sql instances create blog-db --database-version=MYSQL_8_0 --cpu=2 --memory=8GiB --zone=$ZONE --root-password=password123
gcloud sql users create blogdbuser --instance=blog-db --password=password123
gcloud sql instances patch blog-db --authorized-networks=$VM_IP
#----PRESS Y--------