Предполагая, что Terraform 0.12.x, вы можете сделать это с помощью переменной типа списка (Ref: https://www.terraform.io/docs/configuration/variables.html)
В вашем main.tf (или любом другом файле Terraform, который вы используете):
variable "account_scopes" {
default = []
type = list(string)
description = "List of service account scopes"
}
resource "google_compute_instance" "default" {
name = "Hostname"
machine_type = "n1-standard-2"
zone = "us-central1-b"
boot_disk {
initialize_params {
image = "projects/centos-cloud/global/images/centos-8-v20191018"
}
}
scratch_disk {
}
network_interface {
network = "default"
}
service_account {
scopes = var.account_scopes
}
}
terraform.auto.tfvars
account_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/pubsub",
"https://www.googleapis.com/auth/service.management.readonly",
"https://www.googleapis.com/auth/servicecontrol",
"https://www.googleapis.com/auth/trace.append",
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/cloud-platform.read-only",
"https://www.googleapis.com/auth/cloudplatformprojects",
"https://www.googleapis.com/auth/cloudplatformprojects.readonly"
]