Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ module "obs_restricted_eu_de" {
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
| <a name="requirement_errorcheck"></a> [errorcheck](#requirement\_errorcheck) | 3.0.3 |
| <a name="requirement_opentelekomcloud"></a> [opentelekomcloud](#requirement\_opentelekomcloud) | ~> 1.35 |
| <a name="requirement_opentelekomcloud"></a> [opentelekomcloud](#requirement\_opentelekomcloud) | ~> 1.36 |
| <a name="requirement_random"></a> [random](#requirement\_random) | ~> 3.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_errorcheck"></a> [errorcheck](#provider\_errorcheck) | 3.0.3 |
| <a name="provider_opentelekomcloud"></a> [opentelekomcloud](#provider\_opentelekomcloud) | ~> 1.35 |
| <a name="provider_opentelekomcloud"></a> [opentelekomcloud](#provider\_opentelekomcloud) | ~> 1.36 |
| <a name="provider_random"></a> [random](#provider\_random) | ~> 3.0 |

## Modules
Expand Down Expand Up @@ -74,7 +74,9 @@ No modules.
| <a name="input_bucket_name"></a> [bucket\_name](#input\_bucket\_name) | Bucket name. Make sure the provider for this module has tennant\_name=<region> set | `string` | n/a | yes |
| <a name="input_enable_versioning"></a> [enable\_versioning](#input\_enable\_versioning) | Disable the versioning for the bucket. Default: true | `bool` | `true` | no |
| <a name="input_force_destroy"></a> [force\_destroy](#input\_force\_destroy) | Destroy all objects from the bucket so that the bucket can be destroyed without error. | `bool` | `false` | no |
| <a name="input_lifecycle_rules"></a> [lifecycle\_rules](#input\_lifecycle\_rules) | Lifecycle rules for the bucket. Default: null | <pre>list(object({<br/> name = string<br/> enabled = bool<br/> prefix = optional(string)<br/> tags = optional(list(object({<br/> key = string<br/> value = string<br/> })))<br/> expiration = optional(object({<br/> days = number<br/> }))<br/> transitions = optional(list(object({<br/> days = number<br/> storage_class = string<br/> })))<br/> noncurrent_version_expiration = optional(object({<br/> days = number<br/> }))<br/> noncurrent_version_transitions = optional(list(object({<br/> days = number<br/> storage_class = string<br/> })))<br/> abort_incomplete_multipart_upload = optional(object({<br/> days = number<br/> }))<br/> }))</pre> | `[]` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | n/a | `map(string)` | `null` | no |
| <a name="input_worm_policy"></a> [worm\_policy](#input\_worm\_policy) | [Optional] Enables and sets number of years OR days for the WORM policy retention period. Only one can be set, not both. | <pre>object({<br/> years = optional(number)<br/> days = optional(number)<br/> })</pre> | `null` | no |

## Outputs

Expand Down
64 changes: 64 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ resource "opentelekomcloud_kms_key_v1" "bucket_kms_key" {
pending_days = 7
is_enabled = "true"
tags = var.tags

}

resource "opentelekomcloud_obs_bucket" "bucket" {
Expand All @@ -20,4 +21,67 @@ resource "opentelekomcloud_obs_bucket" "bucket" {
kms_key_id = opentelekomcloud_kms_key_v1.bucket_kms_key.id
}
tags = var.tags

dynamic "worm_policy" {
for_each = var.worm_policy != null ? [1] : []
content {
years = var.worm_policy.years
days = var.worm_policy.days
Comment thread
mattef92 marked this conversation as resolved.
}
}

dynamic "lifecycle_rule" {
for_each = var.lifecycle_rules
content {
name = lifecycle_rule.value.name
enabled = lifecycle_rule.value.enabled
prefix = lifecycle_rule.value.prefix

dynamic "tag" {
for_each = lifecycle_rule.value.tags != null ? lifecycle_rule.value.tags : []
content {
key = tag.value.key
value = tag.value.value
}
}

dynamic "expiration" {
for_each = lifecycle_rule.value.expiration != null ? [lifecycle_rule.value.expiration] : []
content {
days = expiration.value.days
}
}

dynamic "transition" {
for_each = lifecycle_rule.value.transitions != null ? lifecycle_rule.value.transitions : []
content {
days = transition.value.days
storage_class = transition.value.storage_class
}
}

dynamic "noncurrent_version_expiration" {
for_each = lifecycle_rule.value.noncurrent_version_expiration != null ? [lifecycle_rule.value.noncurrent_version_expiration] : []
content {
days = noncurrent_version_expiration.value.days
}
}

dynamic "noncurrent_version_transition" {
for_each = lifecycle_rule.value.noncurrent_version_transitions != null ? lifecycle_rule.value.noncurrent_version_transitions : []
content {
days = noncurrent_version_transition.value.days
storage_class = noncurrent_version_transition.value.storage_class
}
}

dynamic "abort_incomplete_multipart_upload" {
for_each = lifecycle_rule.value.abort_incomplete_multipart_upload != null ? [lifecycle_rule.value.abort_incomplete_multipart_upload] : []
content {
days = abort_incomplete_multipart_upload.value.days
}
}
}
}
}

40 changes: 40 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,43 @@ variable "tags" {
type = map(string)
default = null
}

variable "worm_policy" {
type = object({
years = optional(number)
days = optional(number)
})
description = "[Optional] Enables and sets number of years OR days for the WORM policy retention period. Only one can be set, not both."
default = null
}

variable "lifecycle_rules" {
type = list(object({
name = string
enabled = bool
prefix = optional(string)
tags = optional(list(object({
key = string
value = string
})))
expiration = optional(object({
days = number
}))
transitions = optional(list(object({
days = number
storage_class = string
})))
noncurrent_version_expiration = optional(object({
days = number
}))
noncurrent_version_transitions = optional(list(object({
days = number
storage_class = string
})))
abort_incomplete_multipart_upload = optional(object({
days = number
}))
}))
description = "Lifecycle rules for the bucket. Default: null"
default = []
}
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ terraform {
required_providers {
opentelekomcloud = {
source = "opentelekomcloud/opentelekomcloud"
version = "~> 1.35"
version = "~> 1.36"
}
errorcheck = {
source = "iits-consulting/errorcheck"
Expand Down