-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathevent-http-cors.tf.j2
126 lines (103 loc) · 4.77 KB
/
event-http-cors.tf.j2
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// GENERATED FILE: DO NOT EDIT
{%- for i in range(max_functions) %}
resource "aws_api_gateway_method" "{{i}}_options_global" {
rest_api_id = "${aws_api_gateway_rest_api.global.id}"
resource_id = "${aws_api_gateway_resource.{{i}}_global.id}"
http_method = "OPTIONS"
authorization = "NONE"
provider = "aws.{{i}}"
count = "${local.api_gateway_{{i}}_count + local.api_gateway_{{i}}_global_count == 2 ? 1 : 0}"
}
resource "aws_api_gateway_integration" "{{i}}_options_global" {
rest_api_id = "${aws_api_gateway_rest_api.global.id}"
resource_id = "${aws_api_gateway_resource.{{i}}_global.id}"
http_method = "${aws_api_gateway_method.{{i}}_options_global.http_method}"
type = "MOCK"
request_templates = {
"application/json" = <<EOF
{ "statusCode": 200 }
EOF
}
provider = "aws.{{i}}"
count = "${local.api_gateway_{{i}}_count + local.api_gateway_{{i}}_global_count == 2 ? 1 : 0}"
}
resource "aws_api_gateway_integration_response" "{{i}}_options_global" {
rest_api_id = "${aws_api_gateway_rest_api.global.id}"
resource_id = "${aws_api_gateway_resource.{{i}}_global.id}"
http_method = "${aws_api_gateway_method.{{i}}_options_global.http_method}"
status_code = "200"
response_parameters = {
"method.response.header.Access-Control-Allow-Headers" = "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'",
"method.response.header.Access-Control-Allow-Methods" = "'POST,OPTIONS,GET,PUT,PATCH,DELETE'",
"method.response.header.Access-Control-Allow-Origin" = "'*'"
}
depends_on = ["aws_api_gateway_integration.{{i}}_options_global"]
provider = "aws.{{i}}"
count = "${local.api_gateway_{{i}}_count + local.api_gateway_{{i}}_global_count == 2 ? 1 : 0}"
}
resource "aws_api_gateway_method_response" "{{i}}_options_global" {
rest_api_id = "${aws_api_gateway_rest_api.global.id}"
resource_id = "${aws_api_gateway_resource.{{i}}_global.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.{{i}}_options_global"]
provider = "aws.{{i}}"
count = "${local.api_gateway_{{i}}_count + local.api_gateway_{{i}}_global_count == 2 ? 1 : 0}"
}
resource "aws_api_gateway_method" "{{i}}_options_regional" {
rest_api_id = "${aws_api_gateway_rest_api.{{i}}_regional.id}"
resource_id = "${aws_api_gateway_resource.{{i}}_regional.id}"
http_method = "OPTIONS"
authorization = "NONE"
provider = "aws.{{i}}"
count = "${local.api_gateway_{{i}}_count + local.api_gateway_{{i}}_regional_count == 2 ? 1 : 0}"
}
resource "aws_api_gateway_integration" "{{i}}_options_regional" {
rest_api_id = "${aws_api_gateway_rest_api.{{i}}_regional.id}"
resource_id = "${aws_api_gateway_resource.{{i}}_regional.id}"
http_method = "${aws_api_gateway_method.{{i}}_options_regional.http_method}"
type = "MOCK"
request_templates = {
"application/json" = <<EOF
{ "statusCode": 200 }
EOF
}
provider = "aws.{{i}}"
count = "${local.api_gateway_{{i}}_count + local.api_gateway_{{i}}_regional_count == 2 ? 1 : 0}"
}
resource "aws_api_gateway_integration_response" "{{i}}_options_regional" {
rest_api_id = "${aws_api_gateway_rest_api.{{i}}_regional.id}"
resource_id = "${aws_api_gateway_resource.{{i}}_regional.id}"
http_method = "${aws_api_gateway_method.{{i}}_options_regional.http_method}"
status_code = "200"
response_parameters = {
"method.response.header.Access-Control-Allow-Headers" = "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'",
"method.response.header.Access-Control-Allow-Methods" = "'POST,OPTIONS,GET,PUT,PATCH,DELETE'",
"method.response.header.Access-Control-Allow-Origin" = "'*'"
}
depends_on = ["aws_api_gateway_integration.{{i}}_options_regional"]
provider = "aws.{{i}}"
count = "${local.api_gateway_{{i}}_count + local.api_gateway_{{i}}_regional_count == 2 ? 1 : 0}"
}
resource "aws_api_gateway_method_response" "{{i}}_options_regional" {
rest_api_id = "${aws_api_gateway_rest_api.{{i}}_regional.id}"
resource_id = "${aws_api_gateway_resource.{{i}}_regional.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.{{i}}_options_regional"]
provider = "aws.{{i}}"
count = "${local.api_gateway_{{i}}_count + local.api_gateway_{{i}}_regional_count == 2 ? 1 : 0}"
}
{%- endfor %}