这是我第一次尝试通过terraform在GCP上创建VM。 main.tf包含
provider "google"{
credentials = file("terrform-gcp-demo-285210-4c273aa368b3.json")
project = "terrform-gcp-demo-285210"
region = "europe-west3"
zone = "europe-west3-a"
}
resource "google_compute_instance" "vm-instance" {
name = "terraform-instance"
machine_type = "f1-micro"
tags = ["creator", "juergen"]
boot_disk {
initialize_params {
image = "debian-cloud/debian-9"
}
}
network_interface {
# A default network is created for all GCP projects
network = "default"
}
}
在terrform-gcp-demo-285210-4c273aa368b3后面,我确实创建了一个具有以下角色的服务帐户: 计算管理员 计算实例管理员(v1) 服务帐户管理员 安全中心管理员
我刚开始学到的东西
google_compute_instance.vm-instance: Creating...
Error: Error loading zone 'europe-west3-a': googleapi: Error 403: Required 'compute.zones.get' permission for 'projects/terrform-gcp-demo-285210/zones/europe-west3-a', forbidden
on main.tf line 8, in resource "google_compute_instance" "vm-instance":
8: resource "google_compute_instance" "vm-instance" {