嘿伙计们, 我想创建一个具有静态内部 IP 的计算实例,因此为了做到这一点,我在资源下方创建了
provider "google" {
project = "fit-visitor-305606"
credentials = "${file("C:/Users/Rohan/Desktop/gvpc/fit.json")}"
region = "asia-south1"
}
resource "google_compute_network" "default" {
name = "my-network"
}
resource "google_compute_subnetwork" "default" {
name = "my-subnet"
ip_cidr_range = "10.0.0.0/16" # 10.0.1.0
region = "asia-south1"
network = google_compute_network.default.id
}
resource "google_compute_address" "internal_with_subnet_and_address" {
name = "my-internal-address"
subnetwork = google_compute_subnetwork.default.id
address_type = "INTERNAL"
address = "10.0.42.42"
region = "asia-south1"
}
resource "google_compute_instance" "default" {
name = "test"
machine_type = "e2-medium"
zone = "asia-south1-a"
tags = ["foo", "bar"]
boot_disk {
initialize_params {
image = "debian-cloud/debian-9"
}
}
// Local SSD disk
scratch_disk {
interface = "SCSI"
}
network_interface {
network = google_compute_network.default.id
access_config {
nat_ip = google_compute_address.internal_with_subnet_and_address.address
}
}
metadata = {
foo = "bar"
}
metadata_startup_script = "echo hi > /test.txt"
}
但VPC创建成功但无法附加到计算引擎