@@ -17,12 +17,19 @@ func dataSourceScalewayVPCPrivateNetwork() *schema.Resource {
17
17
addOptionalFieldsToSchema (dsSchema , "name" , "project_id" )
18
18
19
19
dsSchema ["name" ].ConflictsWith = []string {"private_network_id" }
20
+ dsSchema ["vpc_id" ] = & schema.Schema {
21
+ Type : schema .TypeString ,
22
+ Optional : true ,
23
+ Description : "The ID of the vpc to which the private network belongs to" ,
24
+ ValidateFunc : validationUUIDorUUIDWithLocality (),
25
+ ConflictsWith : []string {"private_network_id" },
26
+ }
20
27
dsSchema ["private_network_id" ] = & schema.Schema {
21
28
Type : schema .TypeString ,
22
29
Optional : true ,
23
30
Description : "The ID of the private network" ,
24
31
ValidateFunc : validationUUIDorUUIDWithLocality (),
25
- ConflictsWith : []string {"name" },
32
+ ConflictsWith : []string {"name" , "vpc_id" },
26
33
}
27
34
28
35
return & schema.Resource {
@@ -50,9 +57,11 @@ func dataSourceScalewayVPCPrivateNetworkRead(ctx context.Context, d *schema.Reso
50
57
return diag .FromErr (err )
51
58
}
52
59
60
+ vpcID , hasVpcIDFilter := d .GetOk ("vpc_id" )
61
+
53
62
foundPN , err := findExact (
54
63
res .PrivateNetworks ,
55
- func (s * vpc.PrivateNetwork ) bool { return s .Name == pnName },
64
+ func (s * vpc.PrivateNetwork ) bool { return s .Name == pnName && ( ! hasVpcIDFilter || s . VpcID == vpcID ) },
56
65
pnName ,
57
66
)
58
67
if err != nil {
0 commit comments