@@ -14,6 +14,7 @@ func TestAccAlloydbInstance_update(t *testing.T) {
14
14
15
15
context := map [string ]interface {}{
16
16
"random_suffix" : acctest .RandString (t , 10 ),
17
+ "network_name" : acctest .BootstrapSharedTestNetwork (t , "alloydbinstance-update" ),
17
18
}
18
19
19
20
acctest .VcrTest (t , resource.TestCase {
@@ -64,7 +65,7 @@ resource "google_alloydb_instance" "default" {
64
65
resource "google_alloydb_cluster" "default" {
65
66
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
66
67
location = "us-central1"
67
- network = "projects/${ data.google_project.project.number}/global/networks/${ google_compute_network.default.name}"
68
+ network = data.google_compute_network.default.id
68
69
69
70
initial_user {
70
71
password = "tf-test-alloydb-cluster%{random_suffix}"
@@ -74,20 +75,20 @@ resource "google_alloydb_cluster" "default" {
74
75
data "google_project" "project" {
75
76
}
76
77
77
- resource "google_compute_network" "default" {
78
- name = "tf-test-alloydb-cluster%{random_suffix }"
78
+ data "google_compute_network" "default" {
79
+ name = "%{network_name }"
79
80
}
80
81
81
82
resource "google_compute_global_address" "private_ip_alloc" {
82
83
name = "tf-test-alloydb-cluster%{random_suffix}"
83
84
address_type = "INTERNAL"
84
85
purpose = "VPC_PEERING"
85
86
prefix_length = 16
86
- network = google_compute_network.default.id
87
+ network = data. google_compute_network.default.id
87
88
}
88
89
89
90
resource "google_service_networking_connection" "vpc_connection" {
90
- network = google_compute_network.default.id
91
+ network = data. google_compute_network.default.id
91
92
service = "servicenetworking.googleapis.com"
92
93
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
93
94
}
@@ -100,6 +101,7 @@ func TestAccAlloydbInstance_createInstanceWithMandatoryFields(t *testing.T) {
100
101
101
102
context := map [string ]interface {}{
102
103
"random_suffix" : acctest .RandString (t , 10 ),
104
+ "network_name" : acctest .BootstrapSharedTestNetwork (t , "alloydbinstance-mandatory" ),
103
105
}
104
106
105
107
acctest .VcrTest (t , resource.TestCase {
@@ -127,25 +129,25 @@ resource "google_alloydb_instance" "default" {
127
129
resource "google_alloydb_cluster" "default" {
128
130
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
129
131
location = "us-central1"
130
- network = "projects/${ data.google_project.project.number}/global/networks/${ google_compute_network.default.name}"
132
+ network = data.google_compute_network.default.id
131
133
}
132
134
133
135
data "google_project" "project" {}
134
136
135
- resource "google_compute_network" "default" {
136
- name = "tf-test-alloydb-cluster%{random_suffix }"
137
+ data "google_compute_network" "default" {
138
+ name = "%{network_name }"
137
139
}
138
140
139
141
resource "google_compute_global_address" "private_ip_alloc" {
140
142
name = "tf-test-alloydb-cluster%{random_suffix}"
141
143
address_type = "INTERNAL"
142
144
purpose = "VPC_PEERING"
143
145
prefix_length = 16
144
- network = google_compute_network.default.id
146
+ network = data. google_compute_network.default.id
145
147
}
146
148
147
149
resource "google_service_networking_connection" "vpc_connection" {
148
- network = google_compute_network.default.id
150
+ network = data. google_compute_network.default.id
149
151
service = "servicenetworking.googleapis.com"
150
152
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
151
153
}
@@ -158,6 +160,7 @@ func TestAccAlloydbInstance_createInstanceWithMaximumFields(t *testing.T) {
158
160
159
161
context := map [string ]interface {}{
160
162
"random_suffix" : acctest .RandString (t , 10 ),
163
+ "network_name" : acctest .BootstrapSharedTestNetwork (t , "alloydbinstance-maximum" ),
161
164
}
162
165
163
166
acctest .VcrTest (t , resource.TestCase {
@@ -204,25 +207,25 @@ resource "google_alloydb_instance" "default" {
204
207
resource "google_alloydb_cluster" "default" {
205
208
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
206
209
location = "us-central1"
207
- network = "projects/${ data.google_project.project.number}/global/networks/${ google_compute_network.default.name}"
210
+ network = data.google_compute_network.default.id
208
211
}
209
212
210
213
data "google_project" "project" {}
211
214
212
- resource "google_compute_network" "default" {
213
- name = "tf-test-alloydb-cluster%{random_suffix }"
215
+ data "google_compute_network" "default" {
216
+ name = "%{network_name }"
214
217
}
215
218
216
219
resource "google_compute_global_address" "private_ip_alloc" {
217
220
name = "tf-test-alloydb-cluster%{random_suffix}"
218
221
address_type = "INTERNAL"
219
222
purpose = "VPC_PEERING"
220
223
prefix_length = 16
221
- network = google_compute_network.default.id
224
+ network = data. google_compute_network.default.id
222
225
}
223
226
224
227
resource "google_service_networking_connection" "vpc_connection" {
225
- network = google_compute_network.default.id
228
+ network = data. google_compute_network.default.id
226
229
service = "servicenetworking.googleapis.com"
227
230
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
228
231
}
@@ -235,6 +238,7 @@ func TestAccAlloydbInstance_createPrimaryAndReadPoolInstance(t *testing.T) {
235
238
236
239
context := map [string ]interface {}{
237
240
"random_suffix" : acctest .RandString (t , 10 ),
241
+ "network_name" : acctest .BootstrapSharedTestNetwork (t , "alloydbinstance-readpool" ),
238
242
}
239
243
240
244
acctest .VcrTest (t , resource.TestCase {
@@ -271,25 +275,25 @@ resource "google_alloydb_instance" "read_pool" {
271
275
resource "google_alloydb_cluster" "default" {
272
276
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
273
277
location = "us-central1"
274
- network = "projects/${ data.google_project.project.number}/global/networks/${ google_compute_network.default.name}"
278
+ network = data.google_compute_network.default.id
275
279
}
276
280
277
281
data "google_project" "project" {}
278
282
279
- resource "google_compute_network" "default" {
280
- name = "tf-test-alloydb-cluster%{random_suffix }"
283
+ data "google_compute_network" "default" {
284
+ name = "%{network_name }"
281
285
}
282
286
283
287
resource "google_compute_global_address" "private_ip_alloc" {
284
288
name = "tf-test-alloydb-cluster%{random_suffix}"
285
289
address_type = "INTERNAL"
286
290
purpose = "VPC_PEERING"
287
291
prefix_length = 16
288
- network = google_compute_network.default.id
292
+ network = data. google_compute_network.default.id
289
293
}
290
294
291
295
resource "google_service_networking_connection" "vpc_connection" {
292
- network = google_compute_network.default.id
296
+ network = data. google_compute_network.default.id
293
297
service = "servicenetworking.googleapis.com"
294
298
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
295
299
}
@@ -302,6 +306,7 @@ func TestAccAlloydbInstance_updateDatabaseFlagInPrimaryInstance(t *testing.T) {
302
306
303
307
context := map [string ]interface {}{
304
308
"random_suffix" : acctest .RandString (t , 10 ),
309
+ "network_name" : acctest .BootstrapSharedTestNetwork (t , "alloydbinstance-updatedb" ),
305
310
}
306
311
307
312
acctest .VcrTest (t , resource.TestCase {
@@ -339,25 +344,25 @@ resource "google_alloydb_instance" "primary" {
339
344
resource "google_alloydb_cluster" "default" {
340
345
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
341
346
location = "us-central1"
342
- network = "projects/${ data.google_project.project.number}/global/networks/${ google_compute_network.default.name}"
347
+ network = data.google_compute_network.default.id
343
348
}
344
349
345
350
data "google_project" "project" {}
346
351
347
- resource "google_compute_network" "default" {
348
- name = "tf-test-alloydb-cluster%{random_suffix }"
352
+ data "google_compute_network" "default" {
353
+ name = "%{network_name }"
349
354
}
350
355
351
356
resource "google_compute_global_address" "private_ip_alloc" {
352
357
name = "tf-test-alloydb-cluster%{random_suffix}"
353
358
address_type = "INTERNAL"
354
359
purpose = "VPC_PEERING"
355
360
prefix_length = 16
356
- network = google_compute_network.default.id
361
+ network = data. google_compute_network.default.id
357
362
}
358
363
359
364
resource "google_service_networking_connection" "vpc_connection" {
360
- network = google_compute_network.default.id
365
+ network = data. google_compute_network.default.id
361
366
service = "servicenetworking.googleapis.com"
362
367
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
363
368
}
@@ -379,25 +384,25 @@ resource "google_alloydb_instance" "primary" {
379
384
resource "google_alloydb_cluster" "default" {
380
385
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
381
386
location = "us-central1"
382
- network = "projects/${ data.google_project.project.number}/global/networks/${ google_compute_network.default.name}"
387
+ network = data.google_compute_network.default.id
383
388
}
384
389
385
390
data "google_project" "project" {}
386
391
387
- resource "google_compute_network" "default" {
388
- name = "tf-test-alloydb-cluster%{random_suffix }"
392
+ data "google_compute_network" "default" {
393
+ name = "%{network_name }"
389
394
}
390
395
391
396
resource "google_compute_global_address" "private_ip_alloc" {
392
397
name = "tf-test-alloydb-cluster%{random_suffix}"
393
398
address_type = "INTERNAL"
394
399
purpose = "VPC_PEERING"
395
400
prefix_length = 16
396
- network = google_compute_network.default.id
401
+ network = data. google_compute_network.default.id
397
402
}
398
403
399
404
resource "google_service_networking_connection" "vpc_connection" {
400
- network = google_compute_network.default.id
405
+ network = data. google_compute_network.default.id
401
406
service = "servicenetworking.googleapis.com"
402
407
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
403
408
}
0 commit comments