Skip to content

Commit 2d92cbe

Browse files
authored
Merge pull request #5 from comet-ml/cleanup-ec2-alb
Cleanup ec2 alb
2 parents 919f810 + 72c71c4 commit 2d92cbe

File tree

6 files changed

+22
-13
lines changed

6 files changed

+22
-13
lines changed

comet-infrastructure/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ module "comet_ec2" {
3636
comet_ec2_volume_size = var.comet_ec2_volume_size
3737
comet_ec2_key = var.comet_ec2_key
3838

39-
alb_enabled = var.enable_ec2_alb
39+
alb_enabled = var.enable_ec2_alb
40+
comet_ec2_alb_sg = var.enable_ec2_alb ? module.comet_ec2_alb[0].comet_alb_sg : null
4041

4142
s3_enabled = var.enable_s3
4243
comet_ml_s3_bucket = var.s3_bucket_name

comet-infrastructure/modules/comet_ec2/main.tf

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ resource "aws_vpc_security_group_ingress_rule" "comet_ec2_ingress_ssh" {
173173
from_port = local.ssh_port
174174
to_port = local.ssh_port
175175
ip_protocol = "tcp"
176-
# make more restrictive
177176
cidr_ipv4 = local.cidr_anywhere
178177
}
179178

@@ -183,7 +182,6 @@ resource "aws_vpc_security_group_ingress_rule" "comet_ec2_ingress_http" {
183182
from_port = local.http_port
184183
to_port = local.http_port
185184
ip_protocol = "tcp"
186-
# make more restrictive
187185
cidr_ipv4 = local.cidr_anywhere
188186
}
189187

@@ -193,20 +191,18 @@ resource "aws_vpc_security_group_ingress_rule" "comet_ec2_ingress_https" {
193191
from_port = local.https_port
194192
to_port = local.https_port
195193
ip_protocol = "tcp"
196-
# make more restrictive
197194
cidr_ipv4 = local.cidr_anywhere
198195
}
199196

200-
/*
201197
resource "aws_vpc_security_group_ingress_rule" "comet_ec2_alb_http" {
198+
count = var.alb_enabled ? 1 : 0
202199
security_group_id = aws_security_group.comet_ec2_sg.id
203200

204-
from_port = local.http_port
205-
to_port = local.http_port
206-
ip_protocol = "tcp"
207-
security_groups = [var.comet_ec2_alb_sg.id]
201+
from_port = local.http_port
202+
to_port = local.http_port
203+
ip_protocol = "tcp"
204+
referenced_security_group_id = var.comet_ec2_alb_sg
208205
}
209-
*/
210206

211207
resource "aws_vpc_security_group_egress_rule" "comet_ec2_egress_any" {
212208
security_group_id = aws_security_group.comet_ec2_sg.id

comet-infrastructure/modules/comet_ec2/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,9 @@ variable "comet_ml_s3_bucket" {
6565
variable "comet_ec2_s3_iam_policy" {
6666
description = "Policy granting access to Comet S3 bucket"
6767
type = string
68+
}
69+
70+
variable "comet_ec2_alb_sg" {
71+
description = "ID of the security group attached to an associated application load balancer, for creating ingress EC2 SG rule"
72+
type = string
6873
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
output "alb_dns_name" {
22
description = "DNS name of the ALB"
33
value = module.alb.lb_dns_name
4+
}
5+
6+
output "comet_alb_sg" {
7+
description = "ID of the security group created for the ALB"
8+
value = aws_security_group.comet_alb_sg.id
49
}

comet-infrastructure/terraform.tfvars

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ availability_zones = ["us-east-1a", "us-east-1b", "us-east-1c"]
1515
comet_public_subnets = ["subnet-012345abcdefghijkl", "subnet-012345abcdefghijkl", "subnet-012345abcdefghijkl"]
1616
comet_private_subnets = ["subnet-012345abcdefghijkl", "subnet-012345abcdefghijkl", "subnet-012345abcdefghijkl"]
1717

18+
# if provisioning comet_ec2_alb, specify the following for the HTTPS listener
19+
#ssl_certificate_arn = ""
20+
1821
# if provisioning comet_elasticache for use with existing compute, set the variable below to specify an SG that connections will be allowed from
1922
elasticache_allow_from_sg = "sg-012345abcdefghijkl"
2023

2124
# if provisioning comet_rds for use with existing compute, set the variable below to specify an SG that connections will be allowed from
2225
rds_allow_from_sg = "sg-012345abcdefghijkl"
2326

2427
s3_bucket_name = "comet-use2-bucket"
25-
rds_root_password = "CHANGE-ME"
26-
ssl_certificate_arn = ""
28+
rds_root_password = "CHANGE-ME"

comet-infrastructure/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ variable "comet_ec2_key" {
122122
variable "ssl_certificate_arn" {
123123
description = "ARN of the ACM certificate to use for the ALB"
124124
type = string
125-
default = ""
125+
default = null
126126
}
127127

128128
#comet_eks

0 commit comments

Comments
 (0)