HTTPS Redirect
Automatically redirect all HTTP requests to HTTPS for secure connections.
module "secure_alb" {
source = "registry.patterneddesigns.ca/patterneddesigns/alb/aws"
version = "3.0.0"
name = "secure-alb"
vpc_id = module.vpc.vpc_id
subnets = module.vpc.public_subnets
http_listeners = [{
port = 80
redirect = {
port = "443"
protocol = "HTTPS"
status_code = "HTTP_301"
}
}]
https_listeners = [{
port = 443
certificate_arn = aws_acm_certificate.main.arn
default_action = {
type = "forward"
target_group_arn = aws_lb_target_group.main.arn
}
}]
}
Key Points
- HTTP listener on port 80 redirects to HTTPS
- Uses HTTP 301 (permanent redirect) for SEO benefits
- HTTPS listener handles all traffic with SSL termination