# Google Cloud Platform (GCP)

#### Instance Template

Steps:

1. 建立 VM Instance (via web)
2. 關閉 VM Instance
3. 建立 Custom Image for VM Instance (via web)
4. 建立 Instance Template for Custom Image (via web) 
    - Boot Disk: Custom Image
    - Region: Global (Recommend)
5. 用 Instance Template 新增多個 VM Instances（via CLI or web）

```bash
# sets up the authentication
gcloud init

# create new VM instances with the template named vm1-template
gcloud compute instances create --zone "Zone" --source-instance-template vm1-template vm2 vm3 vm4 vm5 vm6 vm7 vm8
gcloud compute instances list
```

其他方式大量部署 VM

- [Getting started on GCP with Terraform<svg aria-labelledby="cds-react-aria-439-title" class="css-8blerm" fill="none" focusable="false" height="16" id="bkmrk-" role="img" viewbox="0 0 16 16" width="16"><path clip-rule="evenodd" d="M1.5 3.5H6v1H2.5v9h9V10h1v4.5h-11v-11zM13.5 2.5H10v-1h4.5V6h-1V2.5z" fill="currentColor" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M6.646 8.646l7-7 .708.708-7 7-.708-.708z" fill="currentColor" fill-rule="evenodd"></path></svg>](https://cloud.google.com/community/tutorials/getting-started-on-gcp-with-terraform)
- [Creating groups of unmanaged instances](https://cloud.google.com/compute/docs/instance-groups/creating-groups-of-unmanaged-instances)

#### Quotas

- [<u>https://cloud.google.com/compute/quotas#understanding\_vm\_cpu\_and\_ip\_address\_quotas</u><svg aria-labelledby="cds-react-aria-414-title" class="css-8blerm" fill="none" focusable="false" height="16" id="bkmrk--1" role="img" viewbox="0 0 16 16" width="16"><path clip-rule="evenodd" d="M1.5 3.5H6v1H2.5v9h9V10h1v4.5h-11v-11zM13.5 2.5H10v-1h4.5V6h-1V2.5z" fill="currentColor" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M6.646 8.646l7-7 .708.708-7 7-.708-.708z" fill="currentColor" fill-rule="evenodd"></path></svg>](https://cloud.google.com/compute/quotas#understanding_vm_cpu_and_ip_address_quotas)
- [<u>https://docs.aws.amazon.com/general/latest/gr/aws\_service\_limits.html</u><svg aria-labelledby="cds-react-aria-415-title" class="css-8blerm" fill="none" focusable="false" height="16" id="bkmrk--2" role="img" viewbox="0 0 16 16" width="16"><path clip-rule="evenodd" d="M1.5 3.5H6v1H2.5v9h9V10h1v4.5h-11v-11zM13.5 2.5H10v-1h4.5V6h-1V2.5z" fill="currentColor" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M6.646 8.646l7-7 .708.708-7 7-.708-.708z" fill="currentColor" fill-rule="evenodd"></path></svg>](https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html)
- [<u>https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits#service-specific-limits</u>](https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits#service-specific-limits)

#### Active Cloud Shell  


Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.

> Tip: Cloud Shell 環境已經預裝好 GCP SDK, docker 等開發工具，可以用來執行 gcloud 指令，或者簡易的 docker 操作。

在 GCP 控制台點擊右上角 **Activate Cloud Shell**。

```bash
gcloud auth list
```

```
ACTIVE: *
ACCOUNT: alang.hsu@gmail.com

To set the active account, run:
    $ gcloud config set account `ACCOUNT`
```

```bash
gcloud config list project
```

```
[core]
project = <project_ID>
```