Skip to content

Commit 222a7cd

Browse files
committed
feat(cloud_project_storage): Add field to avoid saving objects in state
Signed-off-by: Arthur Amstutz <[email protected]>
1 parent 2d15e2b commit 222a7cd

12 files changed

+70
-16
lines changed

docs/data-sources/cloud_project_storage.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ data "ovh_cloud_project_storage" "storage" {
2828

2929
### Optional
3030

31+
- `hide_objects` (Boolean) If true, objects list will not be saved in state (useful for large buckets)
3132
- `limit` (Number) Limit the number of objects returned (1000 maximum, defaults to 1000)
3233
- `marker` (String) Key to start with when listing objects
3334
- `prefix` (String) List objects whose key begins with this prefix

docs/data-sources/okms_secret.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,21 @@ In addition to the arguments above, the following attributes are exported:
7070
- `version` (Number) The resolved version number (requested or current latest).
7171
- `data` (String, Sensitive) Raw JSON secret payload (present only if `include_data` is true).
7272
- `metadata` (Block) Secret metadata:
73-
- `cas_required` (Boolean)
74-
- `created_at` (String)
75-
- `updated_at` (String)
76-
- `current_version` (Number)
77-
- `oldest_version` (Number)
78-
- `max_versions` (Number)
79-
- `deactivate_version_after` (String)
80-
- `custom_metadata` (Map of String)
73+
- `cas_required` (Boolean)
74+
- `created_at` (String)
75+
- `updated_at` (String)
76+
- `current_version` (Number)
77+
- `oldest_version` (Number)
78+
- `max_versions` (Number)
79+
- `deactivate_version_after` (String)
80+
- `custom_metadata` (Map of String)
8181
- `iam` (Block) IAM resource metadata:
82-
- `display_name` (String)
83-
- `id` (String)
84-
- `tags` (Map of String)
85-
- `urn` (String)
82+
- `display_name` (String)
83+
- `id` (String)
84+
- `tags` (Map of String)
85+
- `urn` (String)
8686

8787
## Behavior & Notes
8888

8989
- The `data` attribute retains the raw JSON returned by the API. Use `jsondecode()` to work with individual keys.
90-
- Changing only `include_data` (true -> false) will cause the `data` attribute to become null in subsequent refreshes (state no longer holds the payload).
90+
- Changing only `include_data` (true -> false) will cause the `data` attribute to become null in subsequent refreshes (state no longer holds the payload).

docs/resources/cloud_project_storage.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ resource "ovh_cloud_project_storage" "storage" {
3535
### Optional
3636

3737
- `encryption` (Attributes) Encryption configuration (see [below for nested schema](#nestedatt--encryption))
38+
- `hide_objects` (Boolean) If true, objects list will not be saved in state (useful for large buckets)
3839
- `limit` (Number) Limit the number of objects returned (1000 maximum, defaults to 1000)
3940
- `marker` (String) Key to start with when listing objects
4041
- `owner_id` (Number) Container owner user ID

docs/resources/dedicated_server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ resource "ovh_dedicated_server" "server" {
140140
* `raid_level` - Software raid type
141141
* `size` - Partition size in MiB
142142
* `scheme_name` - Partitioning scheme (if applicable with selected operating system)
143-
* `properties` - Deprecated, has no effect
143+
* `properties` - Attribute 'properties' is deprecated and has no effect
144144

145145
### Arguments used to control the lifecycle of a dedicated server
146146

docs/resources/dedicated_server_reinstall_task.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ resource "ovh_dedicated_server_reinstall_task" "server_install" {
128128
http_headers = {
129129
Authorization = "Basic bG9naW46cGFzc3dvcmQ="
130130
}
131-
image_url = "https://github.com/ashmonger/akution_test/releases/download/0.5-compress/deb11k6.qcow2"
131+
image_url = "https://github.com/ashmonger/akution_test/releases/download/0.5-compress/deb11k6.qcow2"
132132
}
133133
}
134134
```
@@ -239,7 +239,7 @@ The following arguments are supported:
239239

240240
~> **WARNING** Some customizations may be required on some Operating Systems. [Check how to list the available and required customization(s) for your operating system](https://help.ovhcloud.com/csm/en-dedicated-servers-api-os-installation?id=kb_article_view&sysparm_article=KB0061951#os-inputs) (do not forget to adapt camel case customization name to snake case parameter).
241241

242-
* `properties` - Deprecated, has no effect
242+
* `properties` - Attribute 'properties' is deprecated and has no effect.
243243

244244
* `storage`: OS reinstallation storage configurations. [More details about disks, hardware/software RAID and partitioning configuration](https://help.ovhcloud.com/csm/en-dedicated-servers-api-partitioning?id=kb_article_view&sysparm_article=KB0043882) (do not forget to adapt camel case parameters to snake case parameters).
245245
* `disk_group_id`: Disk group id to install the OS to (default is 0, meaning automatic).

docs/resources/okms_secret.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,25 @@ output "api_key" {
4747
}
4848
```
4949

50+
# Reading a field from the secret version data:
51+
52+
```terraform
53+
data "ovh_okms_secret" "latest_with_data" {
54+
okms_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
55+
path = "app/api_credentials"
56+
include_data = true
57+
}
58+
59+
locals {
60+
secret_obj = jsondecode(data.ovh_okms_secret.latest_with_data.data)
61+
}
62+
63+
output "api_key" {
64+
value = local.secret_obj.api_key
65+
sensitive = true
66+
}
67+
```
68+
5069
Updating the secret (new version) while enforcing optimistic concurrency control using CAS:
5170

5271
```terraform

ovh/data_cloud_project_storage.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strconv"
88

99
"github.com/hashicorp/terraform-plugin-framework/datasource"
10+
ovhtypes "github.com/ovh/terraform-provider-ovh/v2/ovh/types"
1011
)
1112

1213
var _ datasource.DataSourceWithConfigure = (*cloudProjectStorageDataSource)(nil)
@@ -75,6 +76,10 @@ func (d *cloudProjectStorageDataSource) Read(ctx context.Context, req datasource
7576
return
7677
}
7778

79+
if data.HideObjects.ValueBool() {
80+
data.Objects = ovhtypes.NewListNestedObjectValueOfNull[ObjectsValue](ctx)
81+
}
82+
7883
// Save data into Terraform state
7984
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
8085
}

ovh/data_cloud_project_storage_gen.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ovh/resource_cloud_project_storage.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/hashicorp/terraform-plugin-framework/path"
1111
"github.com/hashicorp/terraform-plugin-framework/resource"
1212
"github.com/hashicorp/terraform-plugin-log/tflog"
13+
ovhtypes "github.com/ovh/terraform-provider-ovh/v2/ovh/types"
1314
)
1415

1516
var _ resource.ResourceWithConfigure = (*cloudProjectStorageResource)(nil)
@@ -115,6 +116,10 @@ func (r *cloudProjectStorageResource) Read(ctx context.Context, req resource.Rea
115116

116117
responseData.MergeWith(&data)
117118

119+
if data.HideObjects.ValueBool() {
120+
responseData.Objects = ovhtypes.NewListNestedObjectValueOfNull[ObjectsValue](ctx)
121+
}
122+
118123
// Save updated data into Terraform state
119124
resp.Diagnostics.Append(resp.State.Set(ctx, &responseData)...)
120125
}
@@ -168,6 +173,10 @@ func (r *cloudProjectStorageResource) Update(ctx context.Context, req resource.U
168173

169174
responseData.MergeWith(&planData)
170175

176+
if planData.HideObjects.ValueBool() {
177+
responseData.Objects = ovhtypes.NewListNestedObjectValueOfNull[ObjectsValue](ctx)
178+
}
179+
171180
// Save updated data into Terraform state
172181
resp.Diagnostics.Append(resp.State.Set(ctx, &responseData)...)
173182
}

ovh/resource_cloud_project_storage_gen.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)