diff --git a/README.md b/README.md index 24ceb5b..daa54bf 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ No modules. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [acl](#input\_acl) | Specifies the ACL policy for a bucket | `string` | `"private"` | no | +| [cors\_rules](#input\_cors\_rules) | A configuration of object CORS rules:

* `allowed_origins` - Requests from this origin can access the bucket;
* `allowed_methods` - Specifies the acceptable operation type of buckets and objects;
* `max_age_seconds` - Specifies the duration that your browser can cache CORS responses, expressed in seconds; |
list(object({
allowed_origins = list(string)
allowed_methods = list(string)
max_age_seconds = optional(number, 100)
}))
| `[]` | no | | [force\_destroy](#input\_force\_destroy) | A boolean that indicates all objects should be deleted from the bucket, so that the bucket can be destroyed without error | `bool` | `false` | no | | [lifecycle\_rules](#input\_lifecycle\_rules) | A configuration of object lifecycle management:

* `key` - Unique identifier for lifecycle rules, the Rule Name contains a maximum of 255 characters;
* `enabled` - Specifies lifecycle rule status;
* `prefix` - Object key prefix identifying one or more objects to which the rule applies. If omitted, all objects in
the bucket will be managed by the lifecycle rule;
* `expiration_days` - Specifies the number of days when objects that have been last updated are automatically deleted. |
map(object({
enabled = optional(bool, true)
prefix = optional(string, null)
expiration_days = number
}))
| `{}` | no | | [name](#input\_name) | Specifies the name of the Object Store | `string` | n/a | yes | diff --git a/main.tf b/main.tf index 630011b..ac15cc1 100644 --- a/main.tf +++ b/main.tf @@ -24,5 +24,14 @@ resource "huaweicloud_obs_bucket" "main" { } } + dynamic "cors_rule" { + for_each = var.cors_rules + content { + allowed_methods = cors_rule.value.allowed_methods + allowed_origins = cors_rule.value.allowed_origins + max_age_seconds = cors_rule.value.max_age_seconds + } + } + tags = var.tags } diff --git a/variables.tf b/variables.tf index 1c00393..69cf41e 100644 --- a/variables.tf +++ b/variables.tf @@ -81,6 +81,31 @@ DES default = {} } +variable "cors_rules" { + description = <