Skip to content

Commit 7722339

Browse files
authored
feat(lb): add support for project_id in lb (#608)
1 parent 2f4bbab commit 7722339

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

docs/data-sources/lb_ip_beta.md

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ data "scaleway_lb_ip_beta" "my_ip" {
3434

3535
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the organization the LB IP is associated with.
3636

37+
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the LB IP is associated with.
38+
3739
## Attributes Reference
3840

3941
In addition to all above arguments, the following attributes are exported:

docs/resources/lb_beta.md

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ The following arguments are supported:
4545

4646
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the organization the load-balancer is associated with.
4747

48+
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the load-balancer is associated with.
49+
4850
## Attributes Reference
4951

5052
In addition to all arguments above, the following attributes are exported:

scaleway/data_source_lb_ip_beta.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ func dataSourceScalewayLbIPBetaRead(d *schema.ResourceData, m interface{}) error
4040
ipID, ok := d.GetOk("ip_id")
4141
if !ok { // Get IP by region and IP address.
4242
res, err := api.ListIPs(&lb.ListIPsRequest{
43-
Region: region,
44-
IPAddress: expandStringPtr(d.Get("ip_address")),
43+
Region: region,
44+
IPAddress: expandStringPtr(d.Get("ip_address")),
45+
OrganizationID: expandStringPtr(d.Get("organization_id")),
46+
ProjectID: expandStringPtr(d.Get("project_id")),
4547
})
4648
if err != nil {
4749
return err

scaleway/resource_lb_beta.go

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func resourceScalewayLbBeta() *schema.Resource {
5454
},
5555
"region": regionSchema(),
5656
"organization_id": organizationIDSchema(),
57+
"project_id": projectIDSchema(),
5758
},
5859
}
5960
}
@@ -68,6 +69,7 @@ func resourceScalewayLbBetaCreate(d *schema.ResourceData, m interface{}) error {
6869
Region: region,
6970
IPID: expandStringPtr(expandID(d.Get("ip_id"))),
7071
OrganizationID: expandStringPtr(d.Get("organization_id")),
72+
ProjectID: expandStringPtr(d.Get("project_id")),
7173
Name: expandOrGenerateString(d.Get("name"), "lb"),
7274
Type: d.Get("type").(string),
7375
}
@@ -118,6 +120,7 @@ func resourceScalewayLbBetaRead(d *schema.ResourceData, m interface{}) error {
118120
_ = d.Set("name", res.Name)
119121
_ = d.Set("region", string(region))
120122
_ = d.Set("organization_id", res.OrganizationID)
123+
_ = d.Set("project_id", res.ProjectID)
121124
_ = d.Set("tags", res.Tags)
122125
// For now API return lowercase lb type. This should be fix in a near future on the API side
123126
_ = d.Set("type", strings.ToUpper(res.Type))

scaleway/resource_lb_ip_beta.go

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func resourceScalewayLbIPBeta() *schema.Resource {
2424
},
2525
"region": regionSchema(),
2626
"organization_id": organizationIDSchema(),
27+
"project_id": projectIDSchema(),
2728
// Computed
2829
"ip_address": {
2930
Type: schema.TypeString,
@@ -48,6 +49,7 @@ func resourceScalewayLbIPBetaCreate(d *schema.ResourceData, m interface{}) error
4849
createReq := &lb.CreateIPRequest{
4950
Region: region,
5051
OrganizationID: expandStringPtr(d.Get("organization_id")),
52+
ProjectID: expandStringPtr(d.Get("project_id")),
5153
Reverse: expandStringPtr(d.Get("reverse")),
5254
}
5355

@@ -82,6 +84,7 @@ func resourceScalewayLbIPBetaRead(d *schema.ResourceData, m interface{}) error {
8284

8385
_ = d.Set("region", string(region))
8486
_ = d.Set("organization_id", res.OrganizationID)
87+
_ = d.Set("project_id", res.ProjectID)
8588
_ = d.Set("ip_id", res.ID)
8689
_ = d.Set("ip_address", res.IPAddress)
8790
_ = d.Set("reverse", res.Reverse)

0 commit comments

Comments
 (0)