Прежде всего, вы можете попробовать настроить провайдера Google Cloud следующим образом:
# Configure the Google Cloud provider
provider "google" {
credentials = "${file("${var.path_gcp_auth_json_file}")}"
version = "~> 2.2"
}
С файлом variables.tf
# Path to the authentification to GCP json file
variable "path_gcp_auth_json_file" {
description = "Path to the authentication JSON file"
default = "YOUR_PATH_TO_YOUR_JSON_KEY"
}
, если вы хотите быть быстрым ине добавляйте значения default
в файл terraform.tfvars
.
Во-вторых, вы пропустили {
в конце ресурса tests
:
resource "google_compute_instance" "tests" {
name = "project-tests"
project = "video-library-228319"
machine_type = "f1-micro"
zone = "us-west1-a"
tags = ["gcp"]
boot_disk {
initialize_params {
image = "ubuntu-os-cloud/ubuntu-1804-lts"
}
}
network_interface {
network = "default"
access_config {
nat_ip = "${google_compute_address.test-static-ip-address.address}"
}
}
}
И затем, для генерации IP-адресов вам необходимо правильно объявить вычислительный ресурс Terraform:
# Generate IPs
resource "google_compute_address" "test-static-ip-address" {
count = "${var.gcp_ip_count}"
name = "${var.gcp_project_id}-gke-ip-${count.index}"
region = "${var.region}"
}
Каждый "${var.[...]
должен ссылаться на variables.tf
, упомянутый ранее.Значение count
зависит от того, сколько IP-адресов вам нужно.Надеюсь, это поможет.