Skip to content

Commit 53306c7

Browse files
authored
build: enable alb to route codegen endpoints for cli (#83)
1 parent e006837 commit 53306c7

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

terraform/services/codegen/main.tf

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,88 @@ module "codegen_service" {
101101
]
102102
listener_rule_priority = 110
103103
}
104+
105+
# Additional ALB rules to route codegen endpoints from main domain
106+
# These have higher priority than the host-based rule above
107+
108+
# Core code endpoints
109+
resource "aws_lb_listener_rule" "main_domain_code_api" {
110+
listener_arn = local.alb_listener_arn
111+
priority = 105 # Higher priority than host-based rule
112+
113+
action {
114+
type = "forward"
115+
target_group_arn = module.codegen_service.target_group_arn
116+
}
117+
118+
condition {
119+
host_header {
120+
values = ["${var.environment}.storefront.elasticpath.com"]
121+
}
122+
}
123+
124+
condition {
125+
path_pattern {
126+
values = ["/api/v1/code/*"]
127+
}
128+
}
129+
130+
tags = {
131+
Name = "plasmic-${var.environment}-main-to-codegen-code"
132+
}
133+
}
134+
135+
# Project-specific code endpoints
136+
resource "aws_lb_listener_rule" "main_domain_project_code" {
137+
listener_arn = local.alb_listener_arn
138+
priority = 106
139+
140+
action {
141+
type = "forward"
142+
target_group_arn = module.codegen_service.target_group_arn
143+
}
144+
145+
condition {
146+
host_header {
147+
values = ["${var.environment}.storefront.elasticpath.com"]
148+
}
149+
}
150+
151+
condition {
152+
path_pattern {
153+
values = ["/api/v1/projects/*/code/*"]
154+
}
155+
}
156+
157+
tags = {
158+
Name = "plasmic-${var.environment}-main-to-codegen-projects"
159+
}
160+
}
161+
162+
# Localization endpoints
163+
resource "aws_lb_listener_rule" "main_domain_localization" {
164+
listener_arn = local.alb_listener_arn
165+
priority = 107
166+
167+
action {
168+
type = "forward"
169+
target_group_arn = module.codegen_service.target_group_arn
170+
}
171+
172+
condition {
173+
host_header {
174+
values = ["${var.environment}.storefront.elasticpath.com"]
175+
}
176+
}
177+
178+
condition {
179+
path_pattern {
180+
values = ["/api/v1/localization/gen-texts"]
181+
}
182+
}
183+
184+
tags = {
185+
Name = "plasmic-${var.environment}-main-to-codegen-localization"
186+
}
187+
}
188+

0 commit comments

Comments
 (0)