-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda_search_api_gateway.tf
More file actions
45 lines (39 loc) · 1.56 KB
/
Copy pathlambda_search_api_gateway.tf
File metadata and controls
45 lines (39 loc) · 1.56 KB
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
resource "aws_api_gateway_rest_api" "search" {
name = "search"
}
resource "aws_api_gateway_resource" "search" {
rest_api_id = aws_api_gateway_rest_api.search.id
parent_id = aws_api_gateway_rest_api.search.root_resource_id
path_part = "search"
}
resource "aws_api_gateway_method" "search" {
rest_api_id = aws_api_gateway_rest_api.search.id
resource_id = aws_api_gateway_resource.search.id
http_method = "ANY"
authorization = "NONE"
}
resource "aws_api_gateway_integration" "search" {
rest_api_id = aws_api_gateway_rest_api.search.id
resource_id = aws_api_gateway_resource.search.id
http_method = aws_api_gateway_method.search.http_method
type = "AWS_PROXY"
integration_http_method = "POST"
uri = "arn:aws:apigateway:${data.aws_region.current.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.search.arn}/invocations"
}
resource "aws_api_gateway_deployment" "search" {
rest_api_id = aws_api_gateway_rest_api.search.id
stage_name = "prod"
}
resource "aws_api_gateway_stage" "search" {
deployment_id = aws_api_gateway_deployment.search.id
rest_api_id = aws_api_gateway_rest_api.search.id
stage_name = "prod"
depends_on = [aws_api_gateway_deployment.search]
}
resource "aws_lambda_permission" "apigateway_lambda_permission" {
statement_id = "AllowExecutionFromApiGateway"
action = "lambda:InvokeFunction"
function_name = "${aws_lambda_function.search.arn}"
principal = "apigateway.amazonaws.com"
source_arn = "${aws_api_gateway_rest_api.search.execution_arn}/*"
}