Skip to content

Commit a59a5a1

Browse files
committed
chore: add explicit vpc in usage of a private network
1 parent 0ef9e5a commit a59a5a1

19 files changed

+17396
-2284
lines changed

docs/guides/using-vpc-bastion-ssh.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,14 @@ variable "machine_count" {
3434
}
3535
3636
# SCALEWAY VPC PRIVATE NETWORK
37+
resource scaleway_vpc "main" {
38+
region = "fr-par"
39+
}
40+
3741
resource scaleway_vpc_private_network "pn" {
3842
name = "myprivatenetwork"
3943
zone = "fr-par-1"
44+
vpc_id = scaleway_vpc.main.id
4045
}
4146
4247
# SCALEWAY VPC VIRTUAL MACHINES

internal/services/container/container_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,11 +648,15 @@ func TestAccContainer_PrivateNetwork(t *testing.T) {
648648
Steps: []resource.TestStep{
649649
{
650650
Config: `
651+
resource scaleway_vpc main {}
652+
651653
resource scaleway_vpc_private_network pn00 {
652654
name = "test-acc-container-pn-pn00"
655+
vpc_id = scaleway_vpc.main.id
653656
}
654657
resource scaleway_vpc_private_network pn01 {
655658
name = "test-acc-container-pn-pn01"
659+
vpc_id = scaleway_vpc.main.id
656660
}
657661
658662
resource scaleway_container_namespace main {
@@ -675,11 +679,15 @@ func TestAccContainer_PrivateNetwork(t *testing.T) {
675679
},
676680
{
677681
Config: `
682+
resource scaleway_vpc main {}
683+
678684
resource scaleway_vpc_private_network pn00 {
679685
name = "test-acc-container-pn-pn00"
686+
vpc_id = scaleway_vpc.main.id
680687
}
681688
resource scaleway_vpc_private_network pn01 {
682689
name = "test-acc-container-pn-pn01"
690+
vpc_id = scaleway_vpc.main.id
683691
}
684692
685693
resource scaleway_container_namespace main {
@@ -721,11 +729,16 @@ func TestAccContainer_PrivateNetwork(t *testing.T) {
721729
},
722730
{
723731
Config: `
732+
resource scaleway_vpc main {}
733+
724734
resource scaleway_vpc_private_network pn00 {
725735
name = "test-acc-container-pn-pn00"
736+
vpc_id = scaleway_vpc.main.id
726737
}
738+
727739
resource scaleway_vpc_private_network pn01 {
728740
name = "test-acc-container-pn-pn01"
741+
vpc_id = scaleway_vpc.main.id
729742
}
730743
731744
resource scaleway_container_namespace main {

internal/services/container/namespace_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,11 @@ func TestAccNamespace_VPCIntegration(t *testing.T) {
283283
Steps: []resource.TestStep{
284284
{
285285
Config: `
286-
resource scaleway_vpc_private_network main {}
286+
resource scaleway_vpc main {}
287+
288+
resource scaleway_vpc_private_network main {
289+
vpc_id = scaleway_vpc.main.id
290+
}
287291
288292
resource scaleway_container_namespace main {}
289293
@@ -300,7 +304,11 @@ func TestAccNamespace_VPCIntegration(t *testing.T) {
300304
},
301305
{
302306
Config: `
303-
resource scaleway_vpc_private_network main {}
307+
resource scaleway_vpc main {}
308+
309+
resource scaleway_vpc_private_network main {
310+
vpc_id = scaleway_vpc.main.id
311+
}
304312
305313
resource scaleway_container_namespace main {
306314
activate_vpc_integration = true

internal/services/function/function_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,11 +426,16 @@ func TestAccFunction_PrivateNetwork(t *testing.T) {
426426
Steps: []resource.TestStep{
427427
{
428428
Config: `
429+
resource scaleway_vpc main {}
430+
429431
resource scaleway_vpc_private_network pn00 {
430432
name = "test-acc-function-pn-pn00"
433+
vpc_id = scaleway_vpc.main.id
431434
}
435+
432436
resource scaleway_vpc_private_network pn01 {
433437
name = "test-acc-function-pn-pn01"
438+
vpc_id = scaleway_vpc.main.id
434439
}
435440
436441
resource scaleway_function_namespace main {
@@ -456,11 +461,16 @@ func TestAccFunction_PrivateNetwork(t *testing.T) {
456461
},
457462
{
458463
Config: `
464+
resource scaleway_vpc main {}
465+
459466
resource scaleway_vpc_private_network pn00 {
460467
name = "test-acc-function-pn-pn00"
468+
vpc_id = scaleway_vpc.main.id
461469
}
470+
462471
resource scaleway_vpc_private_network pn01 {
463472
name = "test-acc-function-pn-pn01"
473+
vpc_id = scaleway_vpc.main.id
464474
}
465475
466476
resource scaleway_function_namespace main {
@@ -511,11 +521,16 @@ func TestAccFunction_PrivateNetwork(t *testing.T) {
511521
},
512522
{
513523
Config: `
524+
resource scaleway_vpc main {}
525+
514526
resource scaleway_vpc_private_network pn00 {
515527
name = "test-acc-function-pn-pn00"
528+
vpc_id = scaleway_vpc.main.id
516529
}
530+
517531
resource scaleway_vpc_private_network pn01 {
518532
name = "test-acc-function-pn-pn01"
533+
vpc_id = scaleway_vpc.main.id
519534
}
520535
521536
resource scaleway_function_namespace main {

internal/services/function/namespace_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,11 @@ func TestAccFunctionNamespace_VPCIntegration(t *testing.T) {
197197
Steps: []resource.TestStep{
198198
{
199199
Config: `
200-
resource scaleway_vpc_private_network main {}
200+
resource scaleway_vpc main {}
201+
202+
resource scaleway_vpc_private_network main {
203+
vpc_id = scaleway_vpc.main.id
204+
}
201205
202206
resource scaleway_function_namespace main {}
203207
@@ -217,7 +221,11 @@ func TestAccFunctionNamespace_VPCIntegration(t *testing.T) {
217221
},
218222
{
219223
Config: `
220-
resource scaleway_vpc_private_network main {}
224+
resource scaleway_vpc main {}
225+
226+
resource scaleway_vpc_private_network main {
227+
vpc_id = scaleway_vpc.main.id
228+
}
221229
222230
resource scaleway_function_namespace main {
223231
activate_vpc_integration = true

internal/services/instance/private_nic_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ func TestAccPrivateNIC_Basic(t *testing.T) {
2626
Steps: []resource.TestStep{
2727
{
2828
Config: `
29+
resource scaleway_vpc main {}
30+
2931
resource scaleway_vpc_private_network pn01 {
3032
name = "TestAccScalewayInstancePrivateNIC_Basic"
33+
vpc_id = scaleway_vpc.main.id
3134
}
3235
3336
resource "scaleway_instance_server" "server01" {
@@ -64,8 +67,11 @@ func TestAccPrivateNIC_Tags(t *testing.T) {
6467
Steps: []resource.TestStep{
6568
{
6669
Config: `
70+
resource scaleway_vpc main {}
71+
6772
resource scaleway_vpc_private_network pn01 {
6873
name = "TestAccScalewayInstancePrivateNIC_Tags"
74+
vpc_id = scaleway_vpc.main.id
6975
}
7076
7177
resource "scaleway_instance_server" "server01" {
@@ -88,8 +94,11 @@ func TestAccPrivateNIC_Tags(t *testing.T) {
8894
},
8995
{
9096
Config: `
97+
resource scaleway_vpc main {}
98+
9199
resource scaleway_vpc_private_network pn01 {
92100
name = "TestAccScalewayInstancePrivateNIC_Tags"
101+
vpc_id = scaleway_vpc.main.id
93102
}
94103
95104
resource "scaleway_instance_server" "server01" {
@@ -115,8 +124,11 @@ func TestAccPrivateNIC_Tags(t *testing.T) {
115124
},
116125
{
117126
Config: `
127+
resource scaleway_vpc main {}
128+
118129
resource scaleway_vpc_private_network pn01 {
119130
name = "TestAccScalewayInstancePrivateNIC_Tags"
131+
vpc_id = scaleway_vpc.main.id
120132
}
121133
122134
resource "scaleway_instance_server" "server01" {

internal/services/instance/server_test.go

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,8 +1118,13 @@ func TestAccServer_PrivateNetwork(t *testing.T) {
11181118
Steps: []resource.TestStep{
11191119
{
11201120
Config: `
1121+
resource scaleway_vpc main {
1122+
region = "fr-par"
1123+
}
1124+
11211125
resource scaleway_vpc_private_network internal {
11221126
name = "private_network_instance"
1127+
vpc_id = scaleway_vpc.main.id
11231128
}
11241129
11251130
resource "scaleway_instance_server" "base" {
@@ -1146,8 +1151,11 @@ func TestAccServer_PrivateNetwork(t *testing.T) {
11461151
},
11471152
{
11481153
Config: `
1154+
resource scaleway_vpc main {}
1155+
11491156
resource scaleway_vpc_private_network pn01 {
11501157
name = "private_network_instance"
1158+
vpc_id = scaleway_vpc.main.id
11511159
}
11521160
11531161
resource "scaleway_instance_server" "base" {
@@ -1172,12 +1180,16 @@ func TestAccServer_PrivateNetwork(t *testing.T) {
11721180
},
11731181
{
11741182
Config: `
1183+
resource scaleway_vpc main {}
1184+
11751185
resource scaleway_vpc_private_network pn01 {
11761186
name = "private_network_instance"
1187+
vpc_id = scaleway_vpc.main.id
11771188
}
11781189
11791190
resource scaleway_vpc_private_network pn02 {
11801191
name = "private_network_instance_02"
1192+
vpc_id = scaleway_vpc.main.id
11811193
}
11821194
11831195
resource "scaleway_instance_server" "base" {
@@ -1201,12 +1213,16 @@ func TestAccServer_PrivateNetwork(t *testing.T) {
12011213
},
12021214
{
12031215
Config: `
1216+
resource scaleway_vpc main {}
1217+
12041218
resource scaleway_vpc_private_network pn01 {
12051219
name = "private_network_instance"
1220+
vpc_id = scaleway_vpc.main.id
12061221
}
12071222
12081223
resource scaleway_vpc_private_network pn02 {
12091224
name = "private_network_instance_02"
1225+
vpc_id = scaleway_vpc.main.id
12101226
}
12111227
12121228
resource "scaleway_instance_server" "base" {
@@ -1241,12 +1257,16 @@ func TestAccServer_PrivateNetwork(t *testing.T) {
12411257
},
12421258
{
12431259
Config: `
1260+
resource scaleway_vpc main {}
1261+
12441262
resource scaleway_vpc_private_network pn01 {
12451263
name = "private_network_instance"
1264+
vpc_id = scaleway_vpc.main.id
12461265
}
12471266
12481267
resource scaleway_vpc_private_network pn02 {
12491268
name = "private_network_instance_02"
1269+
vpc_id = scaleway_vpc.main.id
12501270
}
12511271
12521272
resource "scaleway_instance_server" "base" {
@@ -1980,7 +2000,11 @@ func TestAccServer_PrivateNetworkMissingPNIC(t *testing.T) {
19802000
Steps: []resource.TestStep{
19812001
{
19822002
Config: `
1983-
resource scaleway_vpc_private_network pn {}
2003+
resource scaleway_vpc main {}
2004+
2005+
resource scaleway_vpc_private_network pn {
2006+
vpc_id = scaleway_vpc.main.id
2007+
}
19842008
19852009
resource "scaleway_instance_server" "main" {
19862010
image = "ubuntu_jammy"
@@ -2004,7 +2028,11 @@ func TestAccServer_PrivateNetworkMissingPNIC(t *testing.T) {
20042028
},
20052029
{
20062030
Config: `
2007-
resource scaleway_vpc_private_network pn {}
2031+
resource scaleway_vpc main {}
2032+
2033+
resource scaleway_vpc_private_network pn {
2034+
vpc_id = scaleway_vpc.main.id
2035+
}
20082036
20092037
resource "scaleway_instance_server" "main" {
20102038
image = "ubuntu_jammy"
@@ -2037,7 +2065,11 @@ func TestAccServer_PrivateNetworkMissingPNIC(t *testing.T) {
20372065
},
20382066
{ // We import private nic as a separate resource to trigger its deletion.
20392067
Config: `
2040-
resource scaleway_vpc_private_network pn {}
2068+
resource scaleway_vpc main {}
2069+
2070+
resource scaleway_vpc_private_network pn {
2071+
vpc_id = scaleway_vpc.main.id
2072+
}
20412073
20422074
resource "scaleway_instance_server" "main" {
20432075
image = "ubuntu_jammy"
@@ -2085,7 +2117,11 @@ func TestAccServer_PrivateNetworkMissingPNIC(t *testing.T) {
20852117
},
20862118
{
20872119
Config: `
2088-
resource scaleway_vpc_private_network pn {}
2120+
resource scaleway_vpc main {}
2121+
2122+
resource scaleway_vpc_private_network pn {
2123+
vpc_id = scaleway_vpc.main.id
2124+
}
20892125
20902126
resource "scaleway_instance_server" "main" {
20912127
image = "ubuntu_jammy"
@@ -2110,7 +2146,11 @@ func TestAccServer_PrivateNetworkMissingPNIC(t *testing.T) {
21102146
},
21112147
{
21122148
Config: `
2113-
resource scaleway_vpc_private_network pn {}
2149+
resource scaleway_vpc main {}
2150+
2151+
resource scaleway_vpc_private_network pn {
2152+
vpc_id = scaleway_vpc.main.id
2153+
}
21142154
21152155
resource "scaleway_instance_server" "main" {
21162156
image = "ubuntu_jammy"

0 commit comments

Comments
 (0)