forked from apparentlymart/terraform-aws-tf-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_download.tf
61 lines (52 loc) · 2.12 KB
/
api_download.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
resource "aws_api_gateway_method" "download_GET" {
rest_api_id = aws_api_gateway_resource.download.rest_api_id
resource_id = aws_api_gateway_resource.download.id
http_method = "GET"
authorization = local.authorizer.mode
authorizer_id = local.authorizer.id
}
resource "aws_api_gateway_integration" "download_GET" {
rest_api_id = aws_api_gateway_method.download_GET.rest_api_id
resource_id = aws_api_gateway_method.download_GET.resource_id
http_method = aws_api_gateway_method.download_GET.http_method
type = "AWS"
uri = "arn:aws:apigateway:us-west-2:dynamodb:action/GetItem"
integration_http_method = "POST"
credentials = var.dynamodb_query_role_arn
request_templates = {
"application/json" = jsonencode({
TableName = var.dynamodb_table_name
Key : {
Id = { S = "$util.urlEncode($input.params('namespace'))/$util.urlEncode($input.params('module'))/$util.urlEncode($input.params('provider'))" }
Version = { S = "$util.urlEncode($input.params('version'))" }
}
})
}
}
resource "aws_api_gateway_method_response" "download_GET_200" {
rest_api_id = aws_api_gateway_method.download_GET.rest_api_id
resource_id = aws_api_gateway_method.download_GET.resource_id
http_method = aws_api_gateway_method.download_GET.http_method
status_code = "200"
response_parameters = {
"method.response.header.X-Terraform-Get" = true
}
}
resource "aws_api_gateway_integration_response" "download_GET_200" {
rest_api_id = aws_api_gateway_integration.download_GET.rest_api_id
resource_id = aws_api_gateway_integration.download_GET.resource_id
http_method = aws_api_gateway_integration.download_GET.http_method
status_code = aws_api_gateway_method_response.download_GET_200.status_code
response_parameters = {
"method.response.header.X-Terraform-Get" = "integration.response.body.Item.Source.S"
}
response_templates = {
"application/json" = <<EOT
#set($inputRoot = $input.path('$'))
{
"version": "$util.escapeJavaScript($inputRoot.Item.Version.S)",
"source": "$util.escapeJavaScript($inputRoot.Item.Source.S)",
}
EOT
}
}