-
Notifications
You must be signed in to change notification settings - Fork 16
/
variables.tf
36 lines (28 loc) · 1.15 KB
/
variables.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
variable "api" {
description = "id of an aws_api_gateway_rest_api resource"
}
variable "resource" {
description = "id of an aws_api_gateway_resource resource"
}
variable "methods" {
type = list(string)
description = "List of permitted HTTP methods. OPTIONS is added by default."
}
variable "origin" {
description = "Permitted origin"
default = "*"
}
variable "headers" {
description = "List of permitted headers. Default headers are alway present unless discard_default_headers variable is set to true"
default = ["Content-Type", "X-Amz-Date", "Authorization", "X-Api-Key", "X-Amz-Security-Token"]
}
variable "discard_default_headers" {
default = false
description = "When set to true to it discards the default permitted headers and only includes those explicitly defined"
}
locals {
methodOptions = "OPTIONS"
defaultHeaders = ["Content-Type", "X-Amz-Date", "Authorization", "X-Api-Key", "X-Amz-Security-Token"]
methods = join(",", distinct(concat(var.methods, [local.methodOptions])))
headers = var.discard_default_headers ? join(",", var.headers) : join(",", distinct(concat(var.headers, local.defaultHeaders)))
}