» google_network_management_connectivity_test

A connectivity test are a static analysis of your resource configurations that enables you to evaluate connectivity to and from Google Cloud resources in your Virtual Private Cloud (VPC) network.

To get more information about ConnectivityTest, see:

» Example Usage - Network Management Connectivity Test Instances

resource "google_network_management_connectivity_test" "instance-test" {
  name = "conn-test-instances"
  source {
    instance = google_compute_instance.source.id
  }

  destination {
    instance = google_compute_instance.destination.id
  }

  protocol = "TCP"
}

resource "google_compute_instance" "source" {
  name = "source-vm"
  machine_type = "n1-standard-1"

  boot_disk {
    initialize_params {
      image = data.google_compute_image.debian_9.id
    }
  }

  network_interface {
    network = google_compute_network.vpc.id
    access_config {
    }
  }
}

resource "google_compute_instance" "destination" {
  name = "dest-vm"
  machine_type = "n1-standard-1"

  boot_disk {
    initialize_params {
      image = data.google_compute_image.debian_9.id
    }
  }

  network_interface {
    network = google_compute_network.vpc.id
    access_config {
    }
  }
}

resource "google_compute_network" "vpc" {
  name = "conn-test-net"
}

data "google_compute_image" "debian_9" {
  family  = "debian-9"
  project = "debian-cloud"
}

» Example Usage - Network Management Connectivity Test Addresses

resource "google_network_management_connectivity_test" "address-test" {
  name = "conn-test-addr"
  source {
      ip_address = google_compute_address.source-addr.address
      project_id = google_compute_address.source-addr.project
      network = google_compute_network.vpc.id
      network_type = "GCP_NETWORK"
  }

  destination {
      ip_address = google_compute_address.dest-addr.address
      project_id = google_compute_address.dest-addr.project
      network = google_compute_network.vpc.id
  }

  protocol = "UDP"
}

resource "google_compute_network" "vpc" {
  name = "connectivity-vpc"
}

resource "google_compute_subnetwork" "subnet" {
  name          = "connectivity-vpc-subnet"
  ip_cidr_range = "10.0.0.0/16"
  region        = "us-central1"
  network       = google_compute_network.vpc.id
}

resource "google_compute_address" "source-addr" {
  name         = "src-addr"
  subnetwork   = google_compute_subnetwork.subnet.id
  address_type = "INTERNAL"
  address      = "10.0.42.42"
  region       = "us-central1"
}

resource "google_compute_address" "dest-addr" {
  name         = "dest-addr"
  subnetwork   = google_compute_subnetwork.subnet.id
  address_type = "INTERNAL"
  address      = "10.0.43.43"
  region       = "us-central1"
}

» Argument Reference

The following arguments are supported:

  • name - (Required) Unique name for the connectivity test.

  • source - (Required) Required. Source specification of the Connectivity Test. You can use a combination of source IP address, virtual machine (VM) instance, or Compute Engine network to uniquely identify the source location. Examples: If the source IP address is an internal IP address within a Google Cloud Virtual Private Cloud (VPC) network, then you must also specify the VPC network. Otherwise, specify the VM instance, which already contains its internal IP address and VPC network information. If the source of the test is within an on-premises network, then you must provide the destination VPC network. If the source endpoint is a Compute Engine VM instance with multiple network interfaces, the instance itself is not sufficient to identify the endpoint. So, you must also specify the source IP address or VPC network. A reachability analysis proceeds even if the source location is ambiguous. However, the test result may include endpoints that you don't intend to test. Structure is documented below.

  • destination - (Required) Required. Destination specification of the Connectivity Test. You can use a combination of destination IP address, Compute Engine VM instance, or VPC network to uniquely identify the destination location. Even if the destination IP address is not unique, the source IP location is unique. Usually, the analysis can infer the destination endpoint from route information. If the destination you specify is a VM instance and the instance has multiple network interfaces, then you must also specify either a destination IP address or VPC network to identify the destination interface. A reachability analysis proceeds even if the destination location is ambiguous. However, the result can include endpoints that you don't intend to test. Structure is documented below.

The source block supports:

  • ip_address - (Optional) The IP address of the endpoint, which can be an external or internal IP. An IPv6 address is only allowed when the test's destination is a global load balancer VIP.

  • port - (Optional) The IP protocol port of the endpoint. Only applicable when protocol is TCP or UDP.

  • instance - (Optional) A Compute Engine instance URI.

  • network - (Optional) A Compute Engine network URI.

  • network_type - (Optional) Type of the network where the endpoint is located. Possible values are GCP_NETWORK and NON_GCP_NETWORK.

  • project_id - (Optional) Project ID where the endpoint is located. The Project ID can be derived from the URI if you provide a VM instance or network URI. The following are two cases where you must provide the project ID:

    1. Only the IP address is specified, and the IP address is within a GCP project.
    2. When you are using Shared VPC and the IP address that you provide is from the service project. In this case, the network that the IP address resides in is defined in the host project.

The destination block supports:

  • ip_address - (Optional) The IP address of the endpoint, which can be an external or internal IP. An IPv6 address is only allowed when the test's destination is a global load balancer VIP.

  • port - (Optional) The IP protocol port of the endpoint. Only applicable when protocol is TCP or UDP.

  • instance - (Optional) A Compute Engine instance URI.

  • network - (Optional) A Compute Engine network URI.

  • project_id - (Optional) Project ID where the endpoint is located. The Project ID can be derived from the URI if you provide a VM instance or network URI. The following are two cases where you must provide the project ID:

    1. Only the IP address is specified, and the IP address is within a GCP project. 2. When you are using Shared VPC and the IP address that you provide is from the service project. In this case, the network that the IP address resides in is defined in the host project.

  • description - (Optional) The user-supplied description of the Connectivity Test. Maximum of 512 characters.

  • protocol - (Optional) IP Protocol of the test. When not provided, "TCP" is assumed.

  • related_projects - (Optional) Other projects that may be relevant for reachability analysis. This is applicable to scenarios where a test can cross project boundaries.

  • labels - (Optional) Resource labels to represent user-provided metadata.

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

» Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • id - an identifier for the resource with format projects/{{project}}/locations/global/connectivityTests/{{name}}

» Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 4 minutes.
  • update - Default is 4 minutes.
  • delete - Default is 4 minutes.

» Import

ConnectivityTest can be imported using any of these accepted formats:

$ terraform import google_network_management_connectivity_test.default projects/{{project}}/locations/global/connectivityTests/{{name}}
$ terraform import google_network_management_connectivity_test.default {{project}}/{{name}}
$ terraform import google_network_management_connectivity_test.default {{name}}

» User Project Overrides

This resource supports User Project Overrides.