-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.tf
55 lines (44 loc) · 1.66 KB
/
main.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
resource "aws_api_gateway_method" "options" {
rest_api_id = var.api_id
resource_id = var.api_resource_id
http_method = "OPTIONS"
authorization = "NONE"
}
resource "aws_api_gateway_integration" "options" {
rest_api_id = var.api_id
resource_id = var.api_resource_id
http_method = aws_api_gateway_method.options.http_method
type = "MOCK"
request_templates = {
"application/json" = "{ \"statusCode\": 200 }"
}
}
resource "aws_api_gateway_integration_response" "options" {
rest_api_id = var.api_id
resource_id = var.api_resource_id
http_method = aws_api_gateway_method.options.http_method
status_code = 200
response_parameters = {
"method.response.header.Access-Control-Allow-Headers" = "'${join(",", var.allowed_headers)}'"
"method.response.header.Access-Control-Allow-Methods" = "'${join(",", var.allowed_methods)}'"
"method.response.header.Access-Control-Allow-Origin" = "'${var.allowed_origin}'"
"method.response.header.Access-Control-Max-Age" = "'${var.allowed_max_age}'"
}
depends_on = [aws_api_gateway_integration.options]
}
resource "aws_api_gateway_method_response" "options" {
rest_api_id = var.api_id
resource_id = var.api_resource_id
http_method = aws_api_gateway_method.options.http_method
status_code = 200
response_parameters = {
"method.response.header.Access-Control-Allow-Headers" = true
"method.response.header.Access-Control-Allow-Methods" = true
"method.response.header.Access-Control-Allow-Origin" = true
"method.response.header.Access-Control-Max-Age" = true
}
response_models = {
"application/json" = "Empty"
}
depends_on = [aws_api_gateway_method.options]
}