From 018450044cf46cc6b59c6f6d26379ba4cad27cbe Mon Sep 17 00:00:00 2001 From: Aram Karapetyan Date: Tue, 10 Sep 2024 10:10:32 +0400 Subject: [PATCH 1/2] fix(DMVP-5181): Add cors variable for support cors configs --- s3.tf | 6 ++++-- tests/s3-configed/0-setup.tf | 25 +++++++++++++++++++++++++ tests/s3-configed/1-example.tf | 21 +++++++++++++++++++++ tests/s3-configed/README.md | 32 ++++++++++++++++++++++++++++++++ variables.tf | 2 ++ 5 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 tests/s3-configed/0-setup.tf create mode 100644 tests/s3-configed/1-example.tf create mode 100644 tests/s3-configed/README.md diff --git a/s3.tf b/s3.tf index abe0502..4363779 100644 --- a/s3.tf +++ b/s3.tf @@ -1,6 +1,7 @@ module "s3" { - source = "dasmeta/s3/aws" - version = "1.2.1" + # source = "dasmeta/s3/aws" + # version = "1.2.1" + source = "git::https://github.com/dasmeta/terraform-aws-s3.git?ref=DMVP-5181" name = var.domain acl = var.s3_configs.acl @@ -12,4 +13,5 @@ module "s3" { versioning = var.s3_configs.versioning website = var.s3_configs.website create_iam_user = var.s3_configs.create_iam_user + cors_rule = var.s3_configs.cors_rule } diff --git a/tests/s3-configed/0-setup.tf b/tests/s3-configed/0-setup.tf new file mode 100644 index 0000000..b2035bf --- /dev/null +++ b/tests/s3-configed/0-setup.tf @@ -0,0 +1,25 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5.0" + } + } + + required_version = ">= 1.3.0" +} + +/** + * set the following env vars so that aws provider will get authenticated before apply: + + export AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxxxxxxx + export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxx +*/ +provider "aws" { + region = "eu-central-1" +} + +provider "aws" { + region = "us-east-1" + alias = "virginia" +} diff --git a/tests/s3-configed/1-example.tf b/tests/s3-configed/1-example.tf new file mode 100644 index 0000000..c697c0a --- /dev/null +++ b/tests/s3-configed/1-example.tf @@ -0,0 +1,21 @@ +module "this" { + source = "../../" + + domain = "basic-test-front-app.devops.dasmeta.com" + zone = "devops.dasmeta.com" + alternative_domains = ["basic-test-front-app-1.devops.dasmeta.com"] + alternative_zones = ["devops.dasmeta.com"] + + s3_configs = { + cors_rule = [ + { + allowed_methods = ["HEAD","GET","PUT", "POST"] + allowed_origins = ["https://modules.tf", "https://dasmeta.modules.tf"] + allowed_headers = ["*"] + expose_headers = ["ETag","Access-Control-Allow-Origin"] + } + ] + } + + providers = { aws : aws, aws.virginia : aws.virginia } +} diff --git a/tests/s3-configed/README.md b/tests/s3-configed/README.md new file mode 100644 index 0000000..aa6258a --- /dev/null +++ b/tests/s3-configed/README.md @@ -0,0 +1,32 @@ +# basic + + +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >= 1.3.0 | +| [aws](#requirement\_aws) | ~> 5.0 | + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [this](#module\_this) | ../../ | n/a | + +## Resources + +No resources. + +## Inputs + +No inputs. + +## Outputs + +No outputs. + diff --git a/variables.tf b/variables.tf index 082f1dd..3ea462f 100644 --- a/variables.tf +++ b/variables.tf @@ -43,6 +43,7 @@ variable "s3_configs" { versioning = optional(object({ enabled = bool }), { enabled = false }) website = optional(object({ index_document = string, error_document = string }), { index_document = "index.html", error_document = "index.html" }) create_iam_user = optional(bool, false) + cors_rule = optional(list(any),[]) }) default = { acl = "private" @@ -59,6 +60,7 @@ variable "s3_configs" { error_document = "index.html" } create_iam_user = false + cors_rule = [] } description = "S3 bucket configuration options" } From 6fb220d2988fb315c5dc14ace377541e8e4b519e Mon Sep 17 00:00:00 2001 From: Aram Karapetyan Date: Tue, 10 Sep 2024 10:14:18 +0400 Subject: [PATCH 2/2] fix(DMVP-5181): Add cors variable for support cors configs --- s3.tf | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/s3.tf b/s3.tf index 4363779..584f512 100644 --- a/s3.tf +++ b/s3.tf @@ -1,7 +1,6 @@ module "s3" { - # source = "dasmeta/s3/aws" - # version = "1.2.1" - source = "git::https://github.com/dasmeta/terraform-aws-s3.git?ref=DMVP-5181" + source = "dasmeta/s3/aws" + version = "1.2.2" name = var.domain acl = var.s3_configs.acl