|
2 | 2 | subcategory : "Key Management Service (KMS)" |
3 | 3 | --- |
4 | 4 |
|
5 | | -# ovh_okms_secret |
| 5 | +# ovh_okms_secret (Resource) |
6 | 6 |
|
7 | 7 | Manages a secret stored in OVHcloud KMS. |
8 | 8 |
|
9 | 9 | > WARNING: `version.data` is marked **Sensitive** but still ends up in the state file. To mitigate that, it is recommended to protect your state with encryption and access controls. Avoid committing it to source control. |
10 | 10 |
|
11 | 11 | ## Example Usage |
12 | 12 |
|
| 13 | +Create a secret whose value is a JSON object. Use `jsonencode()` to produce a deterministic JSON string (ordering/whitespace) to minimize diffs. |
| 14 | + |
13 | 15 | {{tffile "examples/resources/okms_secret/example_1.tf"}} |
14 | 16 |
|
| 17 | +# Reading a field from the secret version data: |
| 18 | + |
| 19 | +{{tffile "examples/data-sources/okms_secret/example_1.tf"}} |
| 20 | + |
| 21 | +Updating the secret (new version) while enforcing optimistic concurrency control using CAS: |
| 22 | + |
| 23 | +{{tffile "examples/resources/okms_secret/example_2.tf"}} |
| 24 | + |
15 | 25 | ## Argument Reference |
16 | 26 |
|
17 | 27 | The following arguments are supported: |
18 | 28 |
|
19 | 29 | ### Required |
20 | 30 |
|
21 | | -* `okms_id` - (Required) ID of the OKMS service to create the secret in. |
22 | | -* `path` - (Required, Forces new resource) Secret path (acts as the secret identifier within the OKMS instance). Immutable after creation. |
23 | | -* `version` - (Required) Block defining the secret version to create/update. See Version Block below. (On updates providing a new `version.data` creates a new version.) |
| 31 | +- `okms_id` (String) ID of the OKMS service to create the secret in. |
| 32 | +- `path` (String) Secret path (acts as the secret identifier within the OKMS instance). Immutable after creation. |
| 33 | +- `version` (Block) Definition of the version to create/update. See Version Block below. (On updates providing a new `version.data` creates a new version.) |
24 | 34 |
|
25 | 35 | ### Optional |
26 | 36 |
|
27 | | -* `cas` - (Optional) Check‑and‑set parameter used only on update (if `cas_required` metadata is set to true) to enforce optimistic concurrency control: its value must equal the current secret version (`metadata.current_version`) for the update to succeed. Ignored on create. |
28 | | -* `metadata` - (Optional) Block of secret metadata configuration (subset of fields are user-settable). See Metadata Block below. |
| 37 | +- `cas` (Number) Check‑and‑set parameter used only on update (if `cas_required` metadata is set to true) to enforce optimistic concurrency control: its value must equal the current secret version (`metadata.current_version`) for the update to succeed. Ignored on create. |
| 38 | +- `metadata` (Block) Secret metadata configuration (subset of fields are user-settable). See Metadata Block below. |
29 | 39 |
|
30 | 40 | ### Metadata Block |
31 | 41 |
|
32 | 42 | User configurable attributes inside `metadata`: |
33 | 43 |
|
34 | | -* `cas_required` - (Optional) If true, the server enforces optimistic concurrency control by requiring the `cas` parameter to match the current version number on every write (update) request. |
35 | | -* `custom_metadata` - (Optional) Map of arbitrary key/value metadata. |
36 | | -* `deactivate_version_after` - (Optional) Duration (e.g. `"24h"`) after which a version is deactivated. `"0s"` (default) means never automatically deactivate. |
37 | | -* `max_versions` - (Optional) Number of versions to retain (default 10). Older versions beyond this limit are pruned. |
| 44 | +- `cas_required` (Boolean) If true, the server will enforce optimistic concurrency control by requiring the `cas` parameter to match the current version number on every write (update) request. |
| 45 | +- `custom_metadata` (Map of String) Arbitrary key/value metadata. |
| 46 | +- `deactivate_version_after` (String) Duration (e.g. `"24h"`) after which a version is deactivated. `"0s"` (default) means never automatically deactivate. |
| 47 | +- `max_versions` (Number) Number of versions to retain (default 10). Older versions beyond this limit are pruned. |
38 | 48 |
|
39 | 49 | Computed (read‑only) metadata attributes: |
40 | 50 |
|
41 | | -* `created_at` - Creation timestamp of the secret. |
42 | | -* `updated_at` - Last update timestamp. |
43 | | -* `current_version` - Current (latest) version number. |
44 | | -* `oldest_version` - Oldest retained version number. |
| 51 | +- `created_at` (String) Creation timestamp of the secret. |
| 52 | +- `updated_at` (String) Last update timestamp. |
| 53 | +- `current_version` (Number) Current (latest) version number. |
| 54 | +- `oldest_version` (Number) Oldest retained version number. |
45 | 55 |
|
46 | 56 | ### Version Block |
47 | 57 |
|
48 | 58 | Required attribute: |
49 | 59 |
|
50 | | -* `data` - (Required, Sensitive) Secret payload. Commonly set with `jsonencode(...)` so that Terraform comparisons are stable. Any valid JSON (object, array, string, number, bool) is accepted. Changing `data` creates a new secret version. |
| 60 | +- `data` (String, Sensitive) Secret payload. Commonly set with `jsonencode(...)` so that Terraform comparisons are stable. Any valid JSON (object, array, string, number, bool) is accepted. Changing `data` creates a new secret version. |
51 | 61 |
|
52 | 62 | Computed (read‑only) attributes: |
53 | 63 |
|
54 | | -* `id` - Version number. |
55 | | -* `created_at` - Version creation timestamp. |
56 | | -* `deactivated_at` - Deactivation timestamp if the version was deactivated. |
57 | | -* `state` - Version state (e.g. `ACTIVE`). |
| 64 | +- `id` (Number) Version number. |
| 65 | +- `created_at` (String) Version creation timestamp. |
| 66 | +- `deactivated_at` (String) Deactivation timestamp if the version was deactivated. |
| 67 | +- `state` (String) Version state (e.g. `ACTIVE`). |
58 | 68 |
|
59 | | -## Attributes Reference |
| 69 | +## Attributes Reference (Read-Only) |
60 | 70 |
|
61 | 71 | In addition to arguments above, the following attributes are exported: |
62 | 72 |
|
63 | | -* `iam` - (Block) IAM metadata: `display_name`, `id`, `tags`, `urn`. |
64 | | -* `metadata.*` - Computed fields as listed above. |
65 | | -* `version.*` - Computed fields as listed above. |
| 73 | +- `iam` (Block) IAM metadata: `display_name`, `id`, `tags`, `urn`. |
| 74 | +- `metadata.*` computed fields as listed above. |
| 75 | +- `version.*` computed fields as listed above. |
66 | 76 |
|
67 | 77 | ## Behavior & Notes |
68 | 78 |
|
69 | | -* Updating with a new `version.data` performs an API PUT that creates a new version; the previous version remains (subject to `max_versions`). |
70 | | -* If `cas_required` is true, all write operations must include a correct `cas` query parameter (the expected current version number). Set `cas = ovh_okms_secret.example.metadata.current_version` to enforce optimistic concurrency. A mismatch causes the API to reject the update (preventing overwriting unseen changes). |
71 | | -* `cas` is ignored on create (no existing version). |
| 79 | +- Updating with a new `version.data` performs an API PUT that creates a new version; the previous version remains (subject to `max_versions`). |
| 80 | +- If `cas_required` is true, all write operations must include a correct `cas` query parameter (the expected current version number). Set `cas = ovh_okms_secret.example.metadata.current_version` to enforce optimistic concurrency. A mismatch causes the API to reject the update (preventing overwriting unseen changes). |
| 81 | +- `cas` is ignored on create (no existing version). |
0 commit comments