Skip to content

Commit 248919c

Browse files
committed
Allow only single CORS origin (string)
1 parent 077e72e commit 248919c

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ resource "aws_api_gateway_integration_response" "cors_integration_response" {
4545
response_parameters = {
4646
"method.response.header.Access-Control-Allow-Headers" = "'${local.headers}'",
4747
"method.response.header.Access-Control-Allow-Methods" = "'${local.methods}'",
48-
"method.response.header.Access-Control-Allow-Origin" = "'${local.origins}'"
48+
"method.response.header.Access-Control-Allow-Origin" = "'${var.origin}'"
4949
}
5050
}

variables.tf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ variable "methods" {
1111
description = "List of permitted HTTP methods. OPTIONS is added by default."
1212
}
1313

14-
variable "origins" {
15-
description = "List of permitted origins"
16-
default = ["*"]
14+
variable "origin" {
15+
description = "Permitted origin"
16+
default = "*"
1717
}
1818

1919

@@ -32,6 +32,5 @@ locals {
3232
defaultHeaders = ["Content-Type", "X-Amz-Date", "Authorization", "X-Api-Key", "X-Amz-Security-Token"]
3333

3434
methods = "${join(",", distinct(concat(var.methods, list(local.methodOptions))))}"
35-
origins = "${join(",", var.origins)}"
3635
headers = "${var.discard_default_headers ? join(",", var.headers) : join(",", distinct(concat(var.headers, local.defaultHeaders)))}"
3736
}

0 commit comments

Comments
 (0)