@@ -2687,6 +2687,23 @@ func TestAccComputeInstance_subnetworkUpdate(t *testing.T) {
2687
2687
})
2688
2688
}
2689
2689
2690
+ func TestAccComputeInstance_subnetworkProjectMustMatchError(t *testing.T) {
2691
+ t.Parallel()
2692
+ instanceName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10))
2693
+ suffix := fmt.Sprintf("%s", acctest.RandString(t, 10))
2694
+ acctest.VcrTest(t, resource.TestCase{
2695
+ PreCheck: func() { acctest.AccTestPreCheck(t) },
2696
+ ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
2697
+ CheckDestroy: testAccCheckComputeInstanceDestroyProducer(t),
2698
+ Steps: []resource.TestStep{
2699
+ {
2700
+ Config: testAccComputeInstance_subnetworkProjectExpectError(suffix, instanceName),
2701
+ ExpectError: regexp.MustCompile("must match subnetwork_project"),
2702
+ },
2703
+ },
2704
+ })
2705
+ }
2706
+
2690
2707
func TestAccComputeInstance_networkIpUpdate(t *testing.T) {
2691
2708
t.Parallel()
2692
2709
@@ -8695,6 +8712,45 @@ func testAccComputeInstance_subnetworkUpdateTwo(suffix, instance string) string
8695
8712
`, suffix, suffix, suffix, suffix, instance)
8696
8713
}
8697
8714
8715
+ func testAccComputeInstance_subnetworkProjectExpectError(suffix, instance string) string {
8716
+ return fmt.Sprintf(`
8717
+ data "google_compute_image" "my_image" {
8718
+ family = "debian-11"
8719
+ project = "debian-cloud"
8720
+ }
8721
+
8722
+ resource "google_compute_network" "inst-test-network" {
8723
+ name = "tf-test-network-%s"
8724
+ auto_create_subnetworks = false
8725
+ }
8726
+
8727
+ resource "google_compute_subnetwork" "inst-test-subnetwork" {
8728
+ name = "tf-test-compute-subnet-%s"
8729
+ ip_cidr_range = "10.0.0.0/16"
8730
+ region = "us-east1"
8731
+ network = google_compute_network.inst-test-network.id
8732
+ }
8733
+
8734
+ resource "google_compute_instance" "foobar" {
8735
+ name = "%s"
8736
+ machine_type = "e2-medium"
8737
+ zone = "us-east1-d"
8738
+ allow_stopping_for_update = true
8739
+
8740
+ boot_disk {
8741
+ initialize_params {
8742
+ image = data.google_compute_image.my_image.id
8743
+ }
8744
+ }
8745
+
8746
+ network_interface {
8747
+ subnetwork = google_compute_subnetwork.inst-test-subnetwork.id
8748
+ subnetwork_project = "placeholder"
8749
+ }
8750
+ }
8751
+ `, suffix, suffix, instance)
8752
+ }
8753
+
8698
8754
func testAccComputeInstance_networkIpUpdate(suffix, instance string) string {
8699
8755
return fmt.Sprintf(`
8700
8756
data "google_compute_image" "my_image" {
0 commit comments