Skip to content

Commit 0c49c9b

Browse files
committed
fix: Repair version suspending
fixes #58
1 parent c666667 commit 0c49c9b

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ module "my_bucket" {
4747
| <a name="input_project_id"></a> [project_id](#input_project_id) | ID of the project the bucket is associated with. If null, ressources will be created in the default project associated with the key. | `string` | `null` | no |
4848
| <a name="input_region"></a> [region](#input_region) | Region in which the bucket should be created. Ressource will be created in the region set at the provider level if null. | `string` | `null` | no |
4949
| <a name="input_tags"></a> [tags](#input_tags) | A list of tags for the bucket. As the Scaleway console does not support key/value tags, tags are written with the format value/value. | `list(string)` | `[]` | no |
50-
| <a name="input_versioning_enabled"></a> [versioning_enabled](#input_versioning_enabled) | Enable versioning. Once you version-enable a bucket, it can never return to an unversioned state. You can, however, suspend versioning on that bucket. | `bool` | `false` | no |
51-
| <a name="input_versioning_lock_configuration"></a> [versioning_lock_configuration](#input_versioning_lock_configuration) | Specifies the Object Lock rule for the bucket. Requires versioning. | ```object({ mode = optional(string, "GOVERNANCE"), days = optional(number), years = optional(number), })``` | ```{ "days": null, "years": null }``` | no |
50+
| <a name="input_versioning_enabled"></a> [versioning_enabled](#input_versioning_enabled) | Enable versioning. Once you version-enable a bucket, it can never return to an unversioned state. You can, however, suspend versioning on that bucket. **Warning:** This variable is ignored when a lock rule is defined. | `bool` | `false` | no |
51+
| <a name="input_versioning_lock_configuration"></a> [versioning_lock_configuration](#input_versioning_lock_configuration) | Specifies the Object Lock rule for the bucket. Requires versioning. | ```object({ mode = optional(string, "GOVERNANCE"), days = optional(number), years = optional(number), })``` | `null` | no |
5252
| <a name="input_website_index"></a> [website_index](#input_website_index) | Website Configuration. | `string` | `null` | no |
5353

5454
## Outputs

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
resource "scaleway_object_bucket" "this" {
22
force_destroy = var.force_destroy
33
name = var.name
4-
object_lock_enabled = var.versioning_enabled
4+
object_lock_enabled = var.versioning_lock_configuration != null ? true : false
55

66
region = var.region
77
project_id = var.project_id
@@ -34,7 +34,7 @@ resource "scaleway_object_bucket" "this" {
3434
}
3535

3636
versioning {
37-
enabled = var.versioning_enabled
37+
enabled = var.versioning_enabled || (var.versioning_lock_configuration != null)
3838
}
3939
}
4040

@@ -47,7 +47,7 @@ resource "scaleway_object_bucket_acl" "this" {
4747
}
4848

4949
resource "scaleway_object_bucket_lock_configuration" "this" {
50-
count = var.versioning_enabled ? 1 : 0
50+
count = var.versioning_lock_configuration != null ? 1 : 0
5151

5252
bucket = scaleway_object_bucket.this.name
5353
project_id = var.project_id

variables.tf

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ variable "tags" {
6969
}
7070

7171
variable "versioning_enabled" {
72-
description = "Enable versioning. Once you version-enable a bucket, it can never return to an unversioned state. You can, however, suspend versioning on that bucket."
72+
description = "Enable versioning. Once you version-enable a bucket, it can never return to an unversioned state. You can, however, suspend versioning on that bucket. **Warning:** This variable is ignored when a lock rule is defined."
7373
type = bool
7474
default = false
7575
}
@@ -81,10 +81,7 @@ variable "versioning_lock_configuration" {
8181
days = optional(number),
8282
years = optional(number),
8383
})
84-
default = {
85-
days = null,
86-
years = null,
87-
}
84+
default = null
8885
}
8986

9087
variable "website_index" {

0 commit comments

Comments
 (0)