@@ -306,6 +306,16 @@ func TestAccScalewayRdbInstance_PrivateNetwork(t *testing.T) {
306
306
ip_id = scaleway_vpc_public_gateway_ip.main.id
307
307
}
308
308
309
+ resource scaleway_vpc_public_gateway_pat_rule main {
310
+ gateway_id = scaleway_vpc_public_gateway.main.id
311
+ private_ip = scaleway_vpc_public_gateway_dhcp.main.address
312
+ private_port = scaleway_rdb_instance.main.private_network.0.port
313
+ public_port = 42
314
+ protocol = "both"
315
+ zone = "nl-ams-1"
316
+ depends_on = [scaleway_vpc_gateway_network.main, scaleway_vpc_private_network.pn02]
317
+ }
318
+
309
319
resource scaleway_vpc_gateway_network main {
310
320
gateway_id = scaleway_vpc_public_gateway.main.id
311
321
private_network_id = scaleway_vpc_private_network.pn02.id
@@ -339,6 +349,26 @@ func TestAccScalewayRdbInstance_PrivateNetwork(t *testing.T) {
339
349
resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "private_network.0.ip_net" , "192.168.1.254/24" ),
340
350
),
341
351
},
352
+ {
353
+ Config : `
354
+ resource scaleway_vpc_private_network pn02 {
355
+ name = "my_private_network"
356
+ zone = "nl-ams-1"
357
+ }
358
+ ` ,
359
+ },
360
+ },
361
+ })
362
+ }
363
+
364
+ func TestAccScalewayRdbInstance_PrivateNetwork_DHCP (t * testing.T ) {
365
+ tt := NewTestTools (t )
366
+ defer tt .Cleanup ()
367
+ resource .ParallelTest (t , resource.TestCase {
368
+ PreCheck : func () { testAccPreCheck (t ) },
369
+ ProviderFactories : tt .ProviderFactories ,
370
+ CheckDestroy : testAccCheckScalewayRdbInstanceDestroy (tt ),
371
+ Steps : []resource.TestStep {
342
372
{
343
373
Config : `
344
374
resource scaleway_vpc_private_network pn02 {
@@ -362,6 +392,16 @@ func TestAccScalewayRdbInstance_PrivateNetwork(t *testing.T) {
362
392
ip_id = scaleway_vpc_public_gateway_ip.main.id
363
393
}
364
394
395
+ resource scaleway_vpc_public_gateway_pat_rule main {
396
+ gateway_id = scaleway_vpc_public_gateway.main.id
397
+ private_ip = scaleway_vpc_public_gateway_dhcp.main.address
398
+ private_port = scaleway_rdb_instance.main.private_network.0.port
399
+ public_port = 42
400
+ protocol = "both"
401
+ zone = "nl-ams-1"
402
+ depends_on = [scaleway_vpc_gateway_network.main, scaleway_vpc_private_network.pn02]
403
+ }
404
+
365
405
resource scaleway_vpc_gateway_network main {
366
406
gateway_id = scaleway_vpc_public_gateway.main.id
367
407
private_network_id = scaleway_vpc_private_network.pn02.id
@@ -371,35 +411,34 @@ func TestAccScalewayRdbInstance_PrivateNetwork(t *testing.T) {
371
411
zone = "nl-ams-1"
372
412
depends_on = [scaleway_vpc_public_gateway_ip.main, scaleway_vpc_private_network.pn02]
373
413
}
374
- ` ,
375
- },
376
- {
377
- Config : `
378
- resource scaleway_vpc_private_network pn02 {
379
- name = "my_private_network_without_attachment"
380
- zone = "nl-ams-1"
381
- }
382
414
383
- resource scaleway_vpc_public_gateway_ip main {
384
- zone = "nl-ams-1"
385
- }
386
-
387
- resource scaleway_vpc_public_gateway main {
388
- name = "foobar"
389
- type = "VPC-GW-S"
390
- zone = "nl-ams-1"
391
- ip_id = scaleway_vpc_public_gateway_ip.main.id
415
+ resource scaleway_rdb_instance main {
416
+ name = "test-rdb"
417
+ node_type = "db-dev-s"
418
+ engine = "PostgreSQL-11"
419
+ is_ha_cluster = false
420
+ disable_backup = true
421
+ user_name = "my_initial_user"
422
+ password = "thiZ_is_v&ry_s3cret"
423
+ region= "nl-ams"
424
+ tags = [ "terraform-test", "scaleway_rdb_instance", "volume", "rdb_pn" ]
425
+ volume_type = "bssd"
426
+ volume_size_in_gb = 10
427
+ private_network {
428
+ ip_net = "192.168.1.254/24" #pool high
429
+ pn_id = "${scaleway_vpc_private_network.pn02.id}"
430
+ }
392
431
}
393
432
` ,
433
+ Check : resource .ComposeTestCheckFunc (
434
+ testAccCheckScalewayRdbExists (tt , "scaleway_rdb_instance.main" ),
435
+ resource .TestCheckResourceAttr ("scaleway_rdb_instance.main" , "private_network.0.ip_net" , "192.168.1.254/24" ),
436
+ ),
394
437
},
395
438
{
396
439
Config : `
397
440
resource scaleway_vpc_private_network pn02 {
398
- name = "my_private_network_without_attachment"
399
- zone = "nl-ams-1"
400
- }
401
-
402
- resource scaleway_vpc_public_gateway_ip main {
441
+ name = "my_private_network"
403
442
zone = "nl-ams-1"
404
443
}
405
444
` ,
0 commit comments