-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_gateway.tf
45 lines (34 loc) · 1.21 KB
/
api_gateway.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
resource "aws_apigatewayv2_api" "this" {
for_each = local.each_govcloud
name = local.courier_name
protocol_type = "HTTP"
}
resource "aws_apigatewayv2_route" "this" {
for_each = local.each_govcloud
api_id = aws_apigatewayv2_api.this[each.key].id
route_key = "$default"
target = "integrations/${aws_apigatewayv2_integration.this[each.key].id}"
}
resource "aws_lambda_permission" "this" {
for_each = local.each_govcloud
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.courier.arn
principal = "apigateway.amazonaws.com"
source_arn = "${aws_apigatewayv2_api.this[each.key].execution_arn}/*/*"
}
resource "aws_apigatewayv2_integration" "this" {
for_each = local.each_govcloud
api_id = aws_apigatewayv2_api.this[each.key].id
integration_type = "AWS_PROXY"
connection_type = "INTERNET"
description = "Lambda example"
integration_method = "POST"
integration_uri = aws_lambda_function.courier.invoke_arn
passthrough_behavior = "WHEN_NO_MATCH"
}
resource "aws_apigatewayv2_stage" "this" {
for_each = local.each_govcloud
api_id = aws_apigatewayv2_api.this[each.key].id
auto_deploy = true
name = "prod"
}