Cant find equivent to the GCP instance --no-address flag

Hello Terraform Community,
I am in the process of writing terraform for Google Cloud configuration. In the process of using the google provider I was not able to find a parameter for google_compute_instance that is the equivalent to the --no-address flag. What would --no-address be in terraform?

Hi @Riprock

Do you mean to create a google compute instance without public (elastic) IP address?

If this is the case, here is my practice:

  1. To assign a public/elastic IP address automatically:
resource "google_compute_instance" "my_instance" {
  ...
  network_interface {
    subnetwork = google_compute_subnetwork.hpc_stack_pub_subnet.self_link
    access_config {
    } // Automatically assign one from GCP's IP pool
  }
  ...
}

hpc-now/infra-as-code/gcp/hpc_stack_gcp.master at master · zhenrong-wang/hpc-now (github.com)

  1. To avoid assigning a public/elastic IP address automatically:
resource "google_compute_instance" "my_instance" {
  ...
  network_interface {
    subnetwork = google_compute_subnetwork.hpc_stack_pub_subnet.self_link
  } // Delete the access_config{} code block
  ...
}

hpc-now/infra-as-code/gcp/hpc_stack_gcp.master at master · zhenrong-wang/hpc-now (github.com)

GCP provider doc: google_compute_instance | Resources | hashicorp/google | Terraform | Terraform Registry

Hope my comment helps.

Zhenrong WANG