-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.tf
64 lines (55 loc) · 2.2 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
55
56
57
58
59
60
61
62
63
64
resource "aws_api_gateway_method" "method" {
rest_api_id = var.api_id
resource_id = var.resource_id
http_method = var.http_method
authorization = var.authorization
request_parameters = var.method_request_parameters
request_validator_id = var.request_validator_id
request_models = {
"application/json" = var.model == "Empty" ? "Empty" : join("", aws_api_gateway_model.model.*.name)
}
}
resource "aws_api_gateway_integration" "integration" {
rest_api_id = var.api_id
resource_id = var.resource_id
http_method = aws_api_gateway_method.method.http_method
integration_http_method = var.integration_http_method
type = var.type
uri = var.uri
credentials = var.credentials
request_templates = var.request_templates
request_parameters = var.integration_request_parameters
}
resource "aws_api_gateway_integration_response" "integration_response" {
count = length(var.responses)
rest_api_id = var.api_id
resource_id = var.resource_id
http_method = aws_api_gateway_method.method.http_method
status_code = var.responses[count.index].status_code
selection_pattern = lookup(var.responses[count.index], "selection_pattern", null)
response_templates = lookup(var.responses[count.index], "templates", {})
response_parameters = zipmap(
lookup(var.responses[count.index], "parameters", []),
lookup(var.responses[count.index], "param_values", [])
)
depends_on = [
aws_api_gateway_method.method,
aws_api_gateway_integration.integration
]
}
resource "aws_api_gateway_method_response" "method_response" {
count = length(var.responses)
rest_api_id = var.api_id
resource_id = var.resource_id
http_method = aws_api_gateway_method.method.http_method
status_code = var.responses[count.index].status_code
response_parameters = zipmap(
lookup(var.responses[count.index], "parameters", []),
lookup(var.responses[count.index], "param_requires", [])
)
response_models = lookup(var.responses[count.index], "models", {})
depends_on = [
aws_api_gateway_method.method,
aws_api_gateway_integration.integration
]
}