From d9f5677e6c7108da0545c85bd6dba4e7306ed550 Mon Sep 17 00:00:00 2001 From: Steven Black Date: Wed, 27 Apr 2022 12:08:41 -0400 Subject: [PATCH] change internal port --- elb.tf | 10 +++++----- groups.tf | 4 ++-- variables.tf | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/elb.tf b/elb.tf index ef5ef05..ee8f552 100644 --- a/elb.tf +++ b/elb.tf @@ -16,11 +16,11 @@ resource "aws_security_group" "elb" { resource "aws_security_group_rule" "elb_egress" { description = "Allow traffic from the ELB to the instances" - from_port = 80 + from_port = var.elb_to_ec2_port protocol = "tcp" security_group_id = aws_security_group.elb.id source_security_group_id = aws_security_group.this.id - to_port = 80 + to_port = var.elb_to_ec2_port type = "egress" } @@ -97,7 +97,7 @@ resource "aws_lb_target_group" "this" { name_prefix = substr(var.name, 0, 6) # Nexus has a bad time if two instances are running at once, so the deregistration delay needs to be short deregistration_delay = 10 - port = "80" + port = var.elb_to_ec2_port protocol = "HTTP" tags = var.tags vpc_id = var.vpc_id @@ -107,7 +107,7 @@ resource "aws_lb_target_group" "this" { interval = 15 matcher = "200-299,302" protocol = "HTTP" - port = "80" + port = var.elb_to_ec2_port } lifecycle { @@ -146,7 +146,7 @@ resource "aws_lb_target_group" "additional_this" { interval = 15 matcher = "200-299,302" protocol = "HTTP" - port = "80" + port = var.elb_to_ec2_port } lifecycle { diff --git a/groups.tf b/groups.tf index 5b4971a..035d7dd 100644 --- a/groups.tf +++ b/groups.tf @@ -27,11 +27,11 @@ resource "aws_security_group_rule" "allow_all" { resource "aws_security_group_rule" "allow_inbound_http_from_lb" { description = "Allow traffic from the load balancer" - from_port = 80 + from_port = var.elb_to_ec2_port protocol = "tcp" security_group_id = aws_security_group.this.id source_security_group_id = aws_security_group.elb.id - to_port = 80 + to_port = var.elb_to_ec2_port type = "ingress" } diff --git a/variables.tf b/variables.tf index 469543d..7a281d4 100644 --- a/variables.tf +++ b/variables.tf @@ -160,6 +160,12 @@ variable "elb_subnets" { type = list(string) } +variable "elb_to_ec2_port" { + default = 80 + description = "Subnets to associate ELB to" + type = number +} + variable "vpc_id" { description = "VPC to create associated resources in"