-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrip-path-prefix-proxy.tf
48 lines (40 loc) · 1.6 KB
/
strip-path-prefix-proxy.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
variable "strip-path-prefix-proxy-appname" {
type = string
description = "The name of the app the proxy should point to"
}
locals {
gateway_name = "preview-proxy"
custom_domainname = data.aws_cloudformation_export.domain_name.value
certificate_arn = module.cert_idealo_cloud.acm_certificate_arn
zone_id = data.aws_cloudformation_export.hosted_zone_id.value
prefix ="/offerpage-preview"
}
resource "aws_apigatewayv2_api" "strip-path-proxy" {
name = local.gateway_name
protocol_type = "HTTP"
description = <<-EOM
"The purpose of this Gateway is to have an endpoint that the Layer7 product can call.
We strip off the path prefix here, because the application depends on `correct` paths."
EOM
disable_execute_api_endpoint = false
target = "https://${var.strip-path-prefix-proxy-appname}.${local.custom_domainname}/{proxy}"
route_key = "${local.prefix}/{proxy+}"
}
resource "aws_apigatewayv2_domain_name" "customdomain" {
domain_name = "${local.gateway_name}.${local.custom_domainname}"
domain_name_configuration {
certificate_arn = local.certificate_arn
endpoint_type = "REGIONAL"
security_policy = "TLS_1_2"
}
}
resource "aws_route53_record" "example" {
name = aws_apigatewayv2_domain_name.customdomain.domain_name
type = "A"
zone_id = local.zone_id
alias {
name = aws_apigatewayv2_domain_name.customdomain.domain_name_configuration[0].target_domain_name
zone_id = aws_apigatewayv2_domain_name.customdomain.domain_name_configuration[0].hosted_zone_id
evaluate_target_health = false
}
}