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:

Open in Cloud Shell

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"
  labels = {
    env = "test"
  }
}

resource "google_compute_instance" "source" {
  name = "source-vm"
  machine_type = "e2-medium"

  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 = "e2-medium"

  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-11"
  project = "debian-cloud"
}
Open in Cloud Shell

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:

The source block supports:

The destination block supports:


Attributes Reference

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

Timeouts

This resource provides the following Timeouts configuration options:

Import

ConnectivityTest can be imported using any of these accepted formats:

In Terraform v1.5.0 and later, use an import block to import ConnectivityTest using one of the formats above. For example:

import {
  id = "projects/{{project}}/locations/global/connectivityTests/{{name}}"
  to = google_network_management_connectivity_test.default
}

When using the terraform import command, ConnectivityTest can be imported using one of the formats above. For example:

$ 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.