2
votes

Trying to create a VM in GCP via terraform with External IP as None.

network_interface {
  network = "projects/other-project-name/global/networks/network-name"
  subnetwork = "projects/other-project-name/regions/us-central1/subnetworks/subnet-name"
  access_config {
    nat_ip = "None"
  }
}  

But nat_ip = "None" is invalid value for the field. And if I do nat_ip = "", it auto assigns External IP.
Here's their documentation: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#nat_ip

1

1 Answers

2
votes

To create a VM in GCP via terraform without External IP, you can just omit the access_config section in network_interface block, as documented here. So you'd have just:

network_interface {
  network = "projects/other-project-name/global/networks/network-name"
  subnetwork = "projects/other-project-name/regions/us-central1/subnetworks/subnet-name"
}