Skip to content

Commit

Permalink
fix(DMVP-5181): Add cors variable for support cors configs
Browse files Browse the repository at this point in the history
  • Loading branch information
aramkarapetian committed Sep 10, 2024
1 parent 2bd26ec commit 0184500
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 2 deletions.
6 changes: 4 additions & 2 deletions s3.tf
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
}
25 changes: 25 additions & 0 deletions tests/s3-configed/0-setup.tf
Original file line number Diff line number Diff line change
@@ -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"
}
21 changes: 21 additions & 0 deletions tests/s3-configed/1-example.tf
Original file line number Diff line number Diff line change
@@ -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 }
}
32 changes: 32 additions & 0 deletions tests/s3-configed/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# basic

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.0 |

## Providers

No providers.

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_this"></a> [this](#module\_this) | ../../ | n/a |

## Resources

No resources.

## Inputs

No inputs.

## Outputs

No outputs.
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2 changes: 2 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -59,6 +60,7 @@ variable "s3_configs" {
error_document = "index.html"
}
create_iam_user = false
cors_rule = []
}
description = "S3 bucket configuration options"
}
Expand Down

0 comments on commit 0184500

Please sign in to comment.