From 908338be81deee24c173e753aed1fd81ef0c0e7e Mon Sep 17 00:00:00 2001
From: Anisimova Karina <51861302+Karina5005@users.noreply.github.com>
Date: Tue, 19 Sep 2023 17:49:55 +0300
Subject: [PATCH] feat: Add CORS rules argument (#10)
---
README.md | 1 +
main.tf | 9 +++++++++
variables.tf | 25 +++++++++++++++++++++++++
3 files changed, 35 insertions(+)
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({| `[]` | 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:
allowed_origins = list(string)
allowed_methods = list(string)
max_age_seconds = optional(number, 100)
}))
map(object({| `{}` | 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 = <
enabled = optional(bool, true)
prefix = optional(string, null)
expiration_days = number
}))