Skip to content

Commit

Permalink
feat: Add options to set Project ID and Region. (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit-garcia authored Feb 7, 2023
1 parent 9ed0aa9 commit 300d00b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ module "my_bucket" {
|------|-------------|------|---------|:--------:|
| <a name="input_name"></a> [name](#input_name) | Name of the bucket. | `string` | n/a | yes |
| <a name="input_force_destroy"></a> [force_destroy](#input_force_destroy) | Enable deletion of objects in bucket before destroying, locked objects or under legal hold are also deleted and not recoverable. | `bool` | `false` | no |
| <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 |
| <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 |
| <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 |
| <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 = string, days = optional(number), years = optional(number), })``` | ```{ "days": null, "mode": "GOVERNANCE", "years": null }``` | no |

Expand Down
6 changes: 5 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ resource "scaleway_object_bucket" "this" {
name = var.name
object_lock_enabled = var.versioning_enabled

region = var.region
project_id = var.project_id

versioning {
enabled = var.versioning_enabled
}
Expand All @@ -11,7 +14,8 @@ resource "scaleway_object_bucket" "this" {
resource "scaleway_object_bucket_lock_configuration" "this" {
count = var.versioning_enabled ? 1 : 0

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

rule {
default_retention {
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ variable "name" {
type = string
}

variable "project_id" {
description = "ID of the project the bucket is associated with. If null, ressources will be created in the default project associated with the key."
type = string
default = null
}

variable "region" {
description = "Region in which the bucket should be created. Ressource will be created in the region set at the provider level if null."
type = string
default = null
}

variable "versioning_enabled" {
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."
type = bool
Expand Down

0 comments on commit 300d00b

Please sign in to comment.