Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions terraform/services/codegen/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,88 @@ module "codegen_service" {
]
listener_rule_priority = 110
}

# Additional ALB rules to route codegen endpoints from main domain
# These have higher priority than the host-based rule above

# Core code endpoints
resource "aws_lb_listener_rule" "main_domain_code_api" {
listener_arn = local.alb_listener_arn
priority = 105 # Higher priority than host-based rule

action {
type = "forward"
target_group_arn = module.codegen_service.target_group_arn
}

condition {
host_header {
values = ["${var.environment}.storefront.elasticpath.com"]
}
}

condition {
path_pattern {
values = ["/api/v1/code/*"]
}
}

tags = {
Name = "plasmic-${var.environment}-main-to-codegen-code"
}
}

# Project-specific code endpoints
resource "aws_lb_listener_rule" "main_domain_project_code" {
listener_arn = local.alb_listener_arn
priority = 106

action {
type = "forward"
target_group_arn = module.codegen_service.target_group_arn
}

condition {
host_header {
values = ["${var.environment}.storefront.elasticpath.com"]
}
}

condition {
path_pattern {
values = ["/api/v1/projects/*/code/*"]
}
}

tags = {
Name = "plasmic-${var.environment}-main-to-codegen-projects"
}
}

# Localization endpoints
resource "aws_lb_listener_rule" "main_domain_localization" {
listener_arn = local.alb_listener_arn
priority = 107

action {
type = "forward"
target_group_arn = module.codegen_service.target_group_arn
}

condition {
host_header {
values = ["${var.environment}.storefront.elasticpath.com"]
}
}

condition {
path_pattern {
values = ["/api/v1/localization/gen-texts"]
}
}

tags = {
Name = "plasmic-${var.environment}-main-to-codegen-localization"
}
}