Skip to content

Commit 8123591

Browse files
al26pyfodil
andauthored
fix(scaleway_lb_ip): add support to precise the zone in which the ip was reserved (#2803)
* fix: data.scaleway_lb_ip/zone is now a argument Signed-off-by: Alban PRATS <[email protected]> * record test * fix --------- Signed-off-by: Alban PRATS <[email protected]> Co-authored-by: Yacine FODIL <[email protected]>
1 parent 213756d commit 8123591

File tree

3 files changed

+1778
-675
lines changed

3 files changed

+1778
-675
lines changed

internal/services/lb/data_source_lb_ip.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ func DataSourceIP() *schema.Resource {
1717
// Generate datasource schema from resource
1818
dsSchema := datasource.SchemaFromResourceSchema(ResourceIP().Schema)
1919

20+
datasource.AddOptionalFieldsToSchema(dsSchema, "project_id", "zone")
21+
2022
dsSchema["ip_address"] = &schema.Schema{
2123
Type: schema.TypeString,
2224
Optional: true,
@@ -30,7 +32,6 @@ func DataSourceIP() *schema.Resource {
3032
ConflictsWith: []string{"ip_address"},
3133
ValidateDiagFunc: verify.IsUUIDorUUIDWithLocality(),
3234
}
33-
dsSchema["project_id"].Optional = true
3435

3536
return &schema.Resource{
3637
ReadContext: DataSourceLbIPRead,

internal/services/lb/data_source_lb_ip_test.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,28 @@ func TestAccDataSourceIP_Basic(t *testing.T) {
2121
resource "scaleway_lb_ip" "test" {
2222
}
2323
24+
resource "scaleway_lb_ip" "test_par_2" {
25+
zone = "fr-par-2"
26+
}
27+
2428
data "scaleway_lb_ip" "test" {
25-
ip_address = "${scaleway_lb_ip.test.ip_address}"
29+
ip_address = scaleway_lb_ip.test.ip_address
2630
}
2731
2832
data "scaleway_lb_ip" "test2" {
29-
ip_id = "${scaleway_lb_ip.test.id}"
33+
ip_id = scaleway_lb_ip.test.id
34+
}
35+
36+
data "scaleway_lb_ip" "test_another_zone" {
37+
ip_address = scaleway_lb_ip.test_par_2.ip_address
38+
zone = "fr-par-2"
3039
}
3140
`,
3241
Check: resource.ComposeTestCheckFunc(
3342
isIPPresent(tt, "data.scaleway_lb_ip.test"),
3443
resource.TestCheckResourceAttrPair("data.scaleway_lb_ip.test", "ip_address", "scaleway_lb_ip.test", "ip_address"),
3544
resource.TestCheckResourceAttrPair("data.scaleway_lb_ip.test2", "ip_address", "scaleway_lb_ip.test", "ip_address"),
45+
resource.TestCheckResourceAttrPair("data.scaleway_lb_ip.test_another_zone", "ip_address", "scaleway_lb_ip.test_par_2", "ip_address"),
3646
),
3747
},
3848
},

0 commit comments

Comments
 (0)