Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(DMVP-5181): Add cors variable for support cors configs #6

Merged
merged 2 commits into from
Sep 10, 2024
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
3 changes: 2 additions & 1 deletion s3.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module "s3" {
source = "dasmeta/s3/aws"
version = "1.2.1"
version = "1.2.2"

name = var.domain
acl = var.s3_configs.acl
Expand All @@ -12,4 +12,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
Loading