-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapi_gateway.tf
50 lines (40 loc) · 1.7 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
46
47
48
49
50
resource "aws_api_gateway_rest_api" "graphql" {
description = "graphql api gateway"
name = "${local.graphql_gateway_name}"
binary_media_types = var.graphql_binary_media_types
}
resource "aws_api_gateway_resource" "graphql" {
rest_api_id = aws_api_gateway_rest_api.graphql.id
parent_id = aws_api_gateway_rest_api.graphql.root_resource_id
path_part = "graphql"
}
resource "aws_api_gateway_method" "graphql" {
rest_api_id = aws_api_gateway_rest_api.graphql.id
resource_id = aws_api_gateway_resource.graphql.id
http_method = "POST"
authorization = "NONE"
}
resource "aws_api_gateway_integration" "graphql_lambda_integration" {
rest_api_id = aws_api_gateway_rest_api.graphql.id
resource_id = aws_api_gateway_resource.graphql.id
http_method = aws_api_gateway_method.graphql.http_method
integration_http_method = "POST"
type = "AWS_PROXY"
uri = aws_lambda_function.graphql.invoke_arn
}
resource "aws_api_gateway_deployment" "graphql" {
depends_on = [aws_api_gateway_method.graphql, aws_api_gateway_integration.graphql_lambda_integration]
description = "Deployment by stage to access the endpoint"
rest_api_id = aws_api_gateway_rest_api.graphql.id
stage_name = var.stage
}
## REGISTER DOMAINS FOR API GATEWAY
resource "aws_api_gateway_domain_name" "graphql" {
domain_name = local.api_graphql_domain
certificate_arn = data.aws_acm_certificate.certificate.arn
}
resource "aws_api_gateway_base_path_mapping" "graphql" {
api_id = aws_api_gateway_rest_api.graphql.id
stage_name = aws_api_gateway_deployment.graphql.stage_name
domain_name = aws_api_gateway_domain_name.graphql.domain_name
}