Skip to content

Commit e1cee81

Browse files
authored
feat(instance): add support for project_id (#609)
1 parent 188a4f5 commit e1cee81

18 files changed

+55
-13
lines changed

docs/data-sources/instance_image.md

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ In addition to all above arguments, the following attributes are exported:
4242

4343
- `organization_id` - The ID of the organization the image is associated with.
4444

45+
- `project_id` - The ID of the project the image is associated with.
46+
4547
- `creation_date` - Date of the image creation.
4648

4749
- `modification_date` - Date of image latest update.

docs/data-sources/instance_security_group.md

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ In addition to all above arguments, the following attributes are exported:
3838

3939
- `organization_id` - The ID of the organization the security group is associated with.
4040

41+
- `project_id` - The ID of the project the security group is associated with.
42+
4143
- `inbound_default_policy` - The default policy on incoming traffic. Possible values are: `accept` or `drop`.
4244

4345
- `outbound_default_policy` - The default policy on outgoing traffic. Possible values are: `accept` or `drop`.

docs/data-sources/instance_server.md

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ You find all the available types on the [pricing page](https://www.scaleway.com/
4343

4444
- `organization_id` - The ID of the organization the server is associated with.
4545

46+
- `project_id` - The ID of the project the server is associated with.
47+
4648
- `tags` - The tags associated with the server.
4749

4850
- `security_group_id` - The [security group](https://developers.scaleway.com/en/products/instance/api/#security-groups-8d7f89) the server is attached to.

docs/data-sources/instance_volume.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ data "scaleway_instance_volume" "my_volume" {
3232

3333
- `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the volume exists.
3434

35-
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the organization the server is associated with.
35+
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the organization the volume is associated with.
36+
37+
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the volume is associated with.
3638

3739
## Attributes Reference
3840

docs/resources/instance_ip.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The following arguments are supported:
2020

2121
- `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the IP should be reserved.
2222
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the organization the IP is associated with.
23+
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the IP is associated with.
2324

2425
## Attributes Reference
2526

docs/resources/instance_placement_group.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ The following arguments are supported:
2222
- `policy_type` - (Defaults to `max_availability`) The [policy type](https://developers.scaleway.com/en/products/instance/api/#placement-groups-d8f653) of the placement group. Possible values are: `low_latency` or `max_availability`.
2323
- `policy_mode` - (Defaults to `optional`) The [policy mode](https://developers.scaleway.com/en/products/instance/api/#placement-groups-d8f653) of the placement group. Possible values are: `optional` or `enforced`.
2424
- `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the placement group should be created.
25-
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the project the placement group is associated with.
25+
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the organization the placement group is associated with.
26+
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the placement group is associated with.
2627

2728
## Attributes Reference
2829

docs/resources/instance_security_group.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ The following arguments are supported:
116116

117117
- `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the security group should be created.
118118

119-
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the project the security group is associated with.
119+
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the organization the security group is associated with.
120+
121+
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the security group is associated with.
120122

121123

122124
The `inbound_rule` and `outbound_rule` block supports:

docs/resources/instance_server.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@ attached to the server. Updates to this field will trigger a stop/start of the s
177177

178178
- `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the server should be created.
179179

180-
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the organization the server is associated with. If you intend to deploy your instance in another project than the default one use your `project_id` instead of the organization id.
180+
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the organization the server is associated with.
181+
If you intend to deploy your instance in another project than the default one use your `project_id` instead of the organization id.
182+
183+
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the server is associated with.
181184

182185

183186
## Attributes Reference

docs/resources/instance_volume.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ The following arguments are supported:
2929
- `name` - (Optional) The name of the volume. If not provided it will be randomly generated.
3030
- `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the volume should be created.
3131
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the organization the volume is associated with.
32+
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the volume is associated with.
3233

3334
## Attributes Reference
3435

scaleway/data_source_instance_image.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func dataSourceScalewayInstanceImage() *schema.Resource {
4242
},
4343
"zone": zoneSchema(),
4444
"organization_id": organizationIDSchema(),
45+
"project_id": projectIDSchema(),
4546

4647
"public": {
4748
Type: schema.TypeBool,
@@ -100,9 +101,11 @@ func dataSourceScalewayInstanceImageRead(d *schema.ResourceData, m interface{})
100101
imageID, ok := d.GetOk("image_id")
101102
if !ok { // Get instance by name, zone, and arch.
102103
res, err := instanceAPI.ListImages(&instance.ListImagesRequest{
103-
Zone: zone,
104-
Name: expandStringPtr(d.Get("name")),
105-
Arch: expandStringPtr(d.Get("architecture")),
104+
Zone: zone,
105+
Name: expandStringPtr(d.Get("name")),
106+
Arch: expandStringPtr(d.Get("architecture")),
107+
Organization: expandStringPtr(d.Get("organization_id")),
108+
Project: expandStringPtr(d.Get("project_id")),
106109
}, scw.WithAllPages())
107110
if err != nil {
108111
return err
@@ -149,6 +152,7 @@ func dataSourceScalewayInstanceImageRead(d *schema.ResourceData, m interface{})
149152
}
150153

151154
_ = d.Set("organization_id", resp.Image.Organization)
155+
_ = d.Set("project_id", resp.Image.Project)
152156
_ = d.Set("architecture", resp.Image.Arch)
153157
_ = d.Set("name", resp.Image.Name)
154158

scaleway/data_source_instance_security_group.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ func dataSourceScalewayInstanceSecurityGroupRead(d *schema.ResourceData, m inter
4141
securityGroupID, ok := d.GetOk("security_group_id")
4242
if !ok {
4343
res, err := instanceAPI.ListSecurityGroups(&instance.ListSecurityGroupsRequest{
44-
Zone: zone,
45-
Name: expandStringPtr(d.Get("name")),
44+
Zone: zone,
45+
Name: expandStringPtr(d.Get("name")),
46+
Organization: expandStringPtr(d.Get("organization_id")),
47+
Project: expandStringPtr(d.Get("project_id")),
4648
}, scw.WithAllPages())
4749
if err != nil {
4850
return err

scaleway/data_source_instance_server.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ func dataSourceScalewayInstanceServerRead(d *schema.ResourceData, m interface{})
4040
serverID, ok := d.GetOk("server_id")
4141
if !ok {
4242
res, err := instanceAPI.ListServers(&instance.ListServersRequest{
43-
Zone: zone,
44-
Name: expandStringPtr(d.Get("name")),
43+
Zone: zone,
44+
Name: expandStringPtr(d.Get("name")),
45+
Organization: expandStringPtr(d.Get("organization_id")),
46+
Project: expandStringPtr(d.Get("project_id")),
4547
})
4648
if err != nil {
4749
return err

scaleway/data_source_instance_volume.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ func dataSourceScalewayInstanceVolumeRead(d *schema.ResourceData, m interface{})
3939
volumeID, ok := d.GetOk("volume_id")
4040
if !ok { // Get volumes by zone and name.
4141
res, err := instanceAPI.ListVolumes(&instance.ListVolumesRequest{
42-
Zone: zone,
43-
Name: expandStringPtr(d.Get("name")),
42+
Zone: zone,
43+
Name: expandStringPtr(d.Get("name")),
44+
Organization: expandStringPtr(d.Get("organization_id")),
45+
Project: expandStringPtr(d.Get("project_id")),
4446
})
4547
if err != nil {
4648
return err

scaleway/resource_instance_ip.go

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func resourceScalewayInstanceIP() *schema.Resource {
3737
},
3838
"zone": zoneSchema(),
3939
"organization_id": organizationIDSchema(),
40+
"project_id": projectIDSchema(),
4041
},
4142
}
4243
}
@@ -50,6 +51,7 @@ func resourceScalewayInstanceIPCreate(d *schema.ResourceData, m interface{}) err
5051
res, err := instanceAPI.CreateIP(&instance.CreateIPRequest{
5152
Zone: zone,
5253
Organization: expandStringPtr(d.Get("organization_id")),
54+
Project: expandStringPtr(d.Get("project_id")),
5355
})
5456
if err != nil {
5557
return err
@@ -82,6 +84,7 @@ func resourceScalewayInstanceIPRead(d *schema.ResourceData, m interface{}) error
8284
_ = d.Set("address", res.IP.Address.String())
8385
_ = d.Set("zone", string(zone))
8486
_ = d.Set("organization_id", res.IP.Organization)
87+
_ = d.Set("project_id", res.IP.Project)
8588
_ = d.Set("reverse", res.IP.Reverse)
8689

8790
return nil

scaleway/resource_instance_placement_group.go

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func resourceScalewayInstancePlacementGroup() *schema.Resource {
5050
},
5151
"zone": zoneSchema(),
5252
"organization_id": organizationIDSchema(),
53+
"project_id": projectIDSchema(),
5354
},
5455
}
5556
}
@@ -64,6 +65,7 @@ func resourceScalewayInstancePlacementGroupCreate(d *schema.ResourceData, m inte
6465
Zone: zone,
6566
Name: expandOrGenerateString(d.Get("name"), "pg"),
6667
Organization: expandStringPtr(d.Get("organization_id")),
68+
Project: expandStringPtr(d.Get("project_id")),
6769
PolicyMode: instance.PlacementGroupPolicyMode(d.Get("policy_mode").(string)),
6870
PolicyType: instance.PlacementGroupPolicyType(d.Get("policy_type").(string)),
6971
})
@@ -97,6 +99,7 @@ func resourceScalewayInstancePlacementGroupRead(d *schema.ResourceData, m interf
9799
_ = d.Set("name", res.PlacementGroup.Name)
98100
_ = d.Set("zone", string(zone))
99101
_ = d.Set("organization_id", res.PlacementGroup.Organization)
102+
_ = d.Set("project_id", res.PlacementGroup.Project)
100103
_ = d.Set("policy_mode", res.PlacementGroup.PolicyMode.String())
101104
_ = d.Set("policy_type", res.PlacementGroup.PolicyType.String())
102105
_ = d.Set("policy_respected", res.PlacementGroup.PolicyRespected)

scaleway/resource_instance_security_group.go

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func resourceScalewayInstanceSecurityGroup() *schema.Resource {
8080
},
8181
"zone": zoneSchema(),
8282
"organization_id": organizationIDSchema(),
83+
"project_id": projectIDSchema(),
8384
},
8485
}
8586
}
@@ -95,6 +96,7 @@ func resourceScalewayInstanceSecurityGroupCreate(d *schema.ResourceData, m inter
9596
Name: expandOrGenerateString(d.Get("name"), "sg"),
9697
Zone: zone,
9798
Organization: expandStringPtr(d.Get("organization_id")),
99+
Project: expandStringPtr(d.Get("project_id")),
98100
Description: d.Get("description").(string),
99101
Stateful: d.Get("stateful").(bool),
100102
InboundDefaultPolicy: instance.SecurityGroupPolicy(d.Get("inbound_default_policy").(string)),
@@ -133,6 +135,7 @@ func resourceScalewayInstanceSecurityGroupRead(d *schema.ResourceData, m interfa
133135

134136
_ = d.Set("zone", zone)
135137
_ = d.Set("organization_id", res.SecurityGroup.Organization)
138+
_ = d.Set("project_id", res.SecurityGroup.Project)
136139
_ = d.Set("name", res.SecurityGroup.Name)
137140
_ = d.Set("stateful", res.SecurityGroup.Stateful)
138141
_ = d.Set("description", res.SecurityGroup.Description)

scaleway/resource_instance_server.go

+4
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ func resourceScalewayInstanceServer() *schema.Resource {
206206
},
207207
"zone": zoneSchema(),
208208
"organization_id": organizationIDSchema(),
209+
"project_id": projectIDSchema(),
209210

210211
// Deprecated and removed.
211212
"disable_public_ip": {
@@ -247,6 +248,7 @@ func resourceScalewayInstanceServerCreate(d *schema.ResourceData, m interface{})
247248
Zone: zone,
248249
Name: expandOrGenerateString(d.Get("name"), "srv"),
249250
Organization: expandStringPtr(d.Get("organization_id")),
251+
Project: expandStringPtr(d.Get("project_id")),
250252
Image: image.ID,
251253
CommercialType: commercialType,
252254
EnableIPv6: d.Get("enable_ipv6").(bool),
@@ -361,6 +363,8 @@ func resourceScalewayInstanceServerRead(d *schema.ResourceData, m interface{}) e
361363
_ = d.Set("security_group_id", newZonedID(zone, response.Server.SecurityGroup.ID).String())
362364
_ = d.Set("enable_ipv6", response.Server.EnableIPv6)
363365
_ = d.Set("enable_dynamic_ip", response.Server.DynamicIPRequired)
366+
_ = d.Set("organization_id", response.Server.Organization)
367+
_ = d.Set("project_id", response.Server.Project)
364368

365369
// Image could be empty in an import context.
366370
image := expandRegionalID(d.Get("image").(string))

scaleway/resource_instance_volume.go

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func resourceScalewayInstanceVolume() *schema.Resource {
6666
Description: "The server associated with this volume",
6767
},
6868
"organization_id": organizationIDSchema(),
69+
"project_id": projectIDSchema(),
6970
"zone": zoneSchema(),
7071
},
7172
}
@@ -82,6 +83,7 @@ func resourceScalewayInstanceVolumeCreate(d *schema.ResourceData, m interface{})
8283
Name: expandOrGenerateString(d.Get("name"), "vol"),
8384
VolumeType: instance.VolumeVolumeType(d.Get("type").(string)),
8485
Organization: expandStringPtr(d.Get("organization_id")),
86+
Project: expandStringPtr(d.Get("project_id")),
8587
}
8688

8789
if size, ok := d.GetOk("size_in_gb"); ok {
@@ -127,6 +129,7 @@ func resourceScalewayInstanceVolumeRead(d *schema.ResourceData, m interface{}) e
127129

128130
_ = d.Set("name", res.Volume.Name)
129131
_ = d.Set("organization_id", res.Volume.Organization)
132+
_ = d.Set("project_id", res.Volume.Project)
130133
_ = d.Set("zone", string(zone))
131134
_ = d.Set("type", res.Volume.VolumeType.String())
132135
_ = d.Set("size_in_gb", uint64(res.Volume.Size/scw.GB))

0 commit comments

Comments
 (0)