-
Notifications
You must be signed in to change notification settings - Fork 16
/
main.tf
52 lines (42 loc) · 1.49 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
resource "aws_api_gateway_method" "cors_method" {
rest_api_id = var.api
resource_id = var.resource
http_method = "OPTIONS"
authorization = "NONE"
}
resource "aws_api_gateway_integration" "cors_integration" {
rest_api_id = var.api
resource_id = var.resource
http_method = aws_api_gateway_method.cors_method.http_method
type = "MOCK"
request_templates = {
"application/json" = <<EOF
{ "statusCode": 200 }
EOF
}
}
resource "aws_api_gateway_method_response" "cors_method_response" {
rest_api_id = var.api
resource_id = var.resource
http_method = aws_api_gateway_method.cors_method.http_method
status_code = "200"
response_models = {
"application/json" = "Empty"
}
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
}
}
resource "aws_api_gateway_integration_response" "cors_integration_response" {
rest_api_id = var.api
resource_id = aws_api_gateway_method.cors_method.resource_id
http_method = aws_api_gateway_method.cors_method.http_method
status_code = aws_api_gateway_method_response.cors_method_response.status_code
response_parameters = {
"method.response.header.Access-Control-Allow-Headers" = "'${local.headers}'"
"method.response.header.Access-Control-Allow-Methods" = "'${local.methods}'"
"method.response.header.Access-Control-Allow-Origin" = "'${var.origin}'"
}
}