-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresponses.tf
104 lines (82 loc) · 3.12 KB
/
responses.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#########################################################
# ------------ Lambda Integration Response ------------ #
#########################################################
resource "aws_api_gateway_method_response" "this_lambda" {
for_each = local.lambdas
rest_api_id = local.rest_api.id
resource_id = aws_api_gateway_resource.this[each.value.path].id
http_method = each.value.method
status_code = "200"
response_models = {
"application/json" = "Empty"
}
depends_on = [aws_api_gateway_method.this_lambda]
}
######################################################
# ------------ SNS Integration Response ------------ #
######################################################
resource "aws_api_gateway_method_response" "this_sns" {
for_each = local.sns_list
rest_api_id = local.rest_api.id
resource_id = aws_api_gateway_resource.this[each.value.path].id
http_method = aws_api_gateway_method.this_pub_sub[each.key].http_method
status_code = "200"
response_parameters = {
"method.response.header.Access-Control-Allow-Origin" = true
}
response_models = {
"application/json" = "Empty"
}
}
resource "aws_api_gateway_integration_response" "this_sns" {
for_each = local.sns_list
rest_api_id = local.rest_api.id
resource_id = aws_api_gateway_integration.this_pub_sub[each.key].resource_id
http_method = aws_api_gateway_method_response.this_sns[each.key].http_method
status_code = aws_api_gateway_method_response.this_sns[each.key].status_code
response_parameters = {
"method.response.header.Access-Control-Allow-Origin" = "'*'"
}
response_templates = {
"application/json" = ""
}
depends_on = [aws_api_gateway_method.this_pub_sub]
}
#######################################
# ------------ CORS Mock ------------ #
#######################################
resource "aws_api_gateway_method_response" "this_cors" {
for_each = local.api_mock_resources
rest_api_id = local.rest_api.id
resource_id = aws_api_gateway_resource.this[each.value].id
http_method = "OPTIONS"
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
}
depends_on = [aws_api_gateway_method.this_cors]
}
resource "aws_api_gateway_integration_response" "this_cors" {
for_each = local.api_mock_resources
rest_api_id = local.rest_api.id
resource_id = aws_api_gateway_resource.this[each.value].id
http_method = "OPTIONS"
status_code = "200"
response_templates = {
"application/json" = ""
}
response_parameters = {
"method.response.header.Access-Control-Allow-Headers" = "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,X-Amz-User-Agent,X-Amzn-Trace-Id'",
"method.response.header.Access-Control-Allow-Methods" = "'OPTIONS,DELETE,GET,HEAD,PATCH,POST,PUT'",
"method.response.header.Access-Control-Allow-Origin" = "'*'"
}
depends_on = [
aws_api_gateway_method_response.this_cors,
aws_api_gateway_integration.this_cors
]
}