Skip to content

Commit ca10e11

Browse files
committed
Update RDS parameter group assignment and variables and fix formatting across all modules
1 parent 559a44e commit ca10e11

File tree

15 files changed

+138
-117
lines changed

15 files changed

+138
-117
lines changed

comet-infrastructure/.terraform.lock.hcl

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

comet-infrastructure/main.tf

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module "comet_vpc" {
1717
source = "./modules/comet_vpc"
1818
count = var.enable_vpc ? 1 : 0
1919
environment = var.environment
20-
20+
2121
eks_enabled = var.enable_eks
2222
single_nat_gateway = var.single_nat_gateway
2323
}
@@ -26,7 +26,7 @@ module "comet_ec2" {
2626
source = "./modules/comet_ec2"
2727
count = var.enable_ec2 ? 1 : 0
2828
environment = var.environment
29-
29+
3030
vpc_id = var.enable_vpc ? module.comet_vpc[0].vpc_id : var.comet_vpc_id
3131
comet_ec2_subnet = var.enable_vpc ? module.comet_vpc[0].public_subnets[0] : var.comet_public_subnets[0]
3232
comet_ec2_ami_type = var.comet_ec2_ami_type
@@ -81,11 +81,11 @@ module "comet_elasticache" {
8181
count = var.enable_elasticache ? 1 : 0
8282
environment = var.environment
8383

84-
vpc_id = var.enable_vpc ? module.comet_vpc[0].vpc_id : var.comet_vpc_id
85-
elasticache_private_subnets = var.enable_vpc ? module.comet_vpc[0].private_subnets : var.comet_private_subnets
86-
elasticache_allow_from_sg = var.enable_ec2 ? module.comet_ec2[0].comet_ec2_sg_id : (
87-
var.enable_eks ? module.comet_eks[0].nodegroup_sg_id : (
88-
var.elasticache_allow_from_sg))
84+
vpc_id = var.enable_vpc ? module.comet_vpc[0].vpc_id : var.comet_vpc_id
85+
elasticache_private_subnets = var.enable_vpc ? module.comet_vpc[0].private_subnets : var.comet_private_subnets
86+
elasticache_allow_from_sg = var.enable_ec2 ? module.comet_ec2[0].comet_ec2_sg_id : (
87+
var.enable_eks ? module.comet_eks[0].nodegroup_sg_id : (
88+
var.elasticache_allow_from_sg))
8989
elasticache_engine = var.elasticache_engine
9090
elasticache_engine_version = var.elasticache_engine_version
9191
elasticache_instance_type = var.elasticache_instance_type
@@ -98,12 +98,12 @@ module "comet_rds" {
9898
count = var.enable_rds ? 1 : 0
9999
environment = var.environment
100100

101-
availability_zones = var.enable_vpc ? module.comet_vpc[0].azs : var.availability_zones
102-
vpc_id = var.enable_vpc ? module.comet_vpc[0].vpc_id : var.comet_vpc_id
103-
rds_private_subnets = var.enable_vpc ? module.comet_vpc[0].private_subnets : var.comet_private_subnets
104-
rds_allow_from_sg = var.enable_ec2 ? module.comet_ec2[0].comet_ec2_sg_id : (
105-
var.enable_eks ? module.comet_eks[0].nodegroup_sg_id : (
106-
var.rds_allow_from_sg))
101+
availability_zones = var.enable_vpc ? module.comet_vpc[0].azs : var.availability_zones
102+
vpc_id = var.enable_vpc ? module.comet_vpc[0].vpc_id : var.comet_vpc_id
103+
rds_private_subnets = var.enable_vpc ? module.comet_vpc[0].private_subnets : var.comet_private_subnets
104+
rds_allow_from_sg = var.enable_ec2 ? module.comet_ec2[0].comet_ec2_sg_id : (
105+
var.enable_eks ? module.comet_eks[0].nodegroup_sg_id : (
106+
var.rds_allow_from_sg))
107107
rds_engine = var.rds_engine
108108
rds_engine_version = var.rds_engine_version
109109
rds_instance_type = var.rds_instance_type
@@ -121,5 +121,5 @@ module "comet_s3" {
121121
count = var.enable_s3 ? 1 : 0
122122
environment = var.environment
123123

124-
comet_s3_bucket = var.s3_bucket_name
124+
comet_s3_bucket = var.s3_bucket_name
125125
}

comet-infrastructure/modules/comet_ec2/main.tf

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -124,28 +124,28 @@ data "aws_ami" "ubuntu22" {
124124
}
125125

126126
resource "aws_instance" "comet_ec2" {
127-
ami = var.comet_ec2_ami_type == "al2" ? data.aws_ami.al2.id : (
128-
var.comet_ec2_ami_type == "rhel7" ? data.aws_ami.rhel7.id : (
129-
var.comet_ec2_ami_type == "rhel8" ? data.aws_ami.rhel8.id : (
130-
var.comet_ec2_ami_type == "rhel9" ? data.aws_ami.rhel9.id : (
131-
var.comet_ec2_ami_type == "ubuntu18" ? data.aws_ami.ubuntu18.id : (
132-
var.comet_ec2_ami_type == "ubuntu20" ? data.aws_ami.ubuntu20.id : (
133-
var.comet_ec2_ami_type == "ubuntu22" ? data.aws_ami.ubuntu22.id : (
134-
null)))))))
127+
ami = var.comet_ec2_ami_type == "al2" ? data.aws_ami.al2.id : (
128+
var.comet_ec2_ami_type == "rhel7" ? data.aws_ami.rhel7.id : (
129+
var.comet_ec2_ami_type == "rhel8" ? data.aws_ami.rhel8.id : (
130+
var.comet_ec2_ami_type == "rhel9" ? data.aws_ami.rhel9.id : (
131+
var.comet_ec2_ami_type == "ubuntu18" ? data.aws_ami.ubuntu18.id : (
132+
var.comet_ec2_ami_type == "ubuntu20" ? data.aws_ami.ubuntu20.id : (
133+
var.comet_ec2_ami_type == "ubuntu22" ? data.aws_ami.ubuntu22.id : (
134+
null)))))))
135135
instance_type = var.comet_ec2_instance_type
136136
key_name = var.comet_ec2_key
137137
count = var.comet_ec2_instance_count
138138
iam_instance_profile = aws_iam_instance_profile.comet-ec2-instance-profile.name
139139
subnet_id = var.comet_ec2_subnet
140140
vpc_security_group_ids = [aws_security_group.comet_ec2_sg.id]
141-
141+
142142
#associate_public_ip_address = true
143143

144144
root_block_device {
145145
volume_type = var.comet_ec2_volume_type
146146
volume_size = var.comet_ec2_volume_size
147147
}
148-
148+
149149
tags = merge(local.tags, {
150150
Name = "${var.environment}-comet-ml-${count.index}"
151151
})
@@ -169,32 +169,32 @@ resource "aws_security_group" "comet_ec2_sg" {
169169

170170
resource "aws_vpc_security_group_ingress_rule" "comet_ec2_ingress_ssh" {
171171
security_group_id = aws_security_group.comet_ec2_sg.id
172-
173-
from_port = local.ssh_port
174-
to_port = local.ssh_port
175-
ip_protocol = "tcp"
172+
173+
from_port = local.ssh_port
174+
to_port = local.ssh_port
175+
ip_protocol = "tcp"
176176
# make more restrictive
177-
cidr_ipv4 = local.cidr_anywhere
177+
cidr_ipv4 = local.cidr_anywhere
178178
}
179179

180180
resource "aws_vpc_security_group_ingress_rule" "comet_ec2_ingress_http" {
181181
security_group_id = aws_security_group.comet_ec2_sg.id
182-
183-
from_port = local.http_port
184-
to_port = local.http_port
185-
ip_protocol = "tcp"
182+
183+
from_port = local.http_port
184+
to_port = local.http_port
185+
ip_protocol = "tcp"
186186
# make more restrictive
187-
cidr_ipv4 = local.cidr_anywhere
187+
cidr_ipv4 = local.cidr_anywhere
188188
}
189189

190190
resource "aws_vpc_security_group_ingress_rule" "comet_ec2_ingress_https" {
191191
security_group_id = aws_security_group.comet_ec2_sg.id
192-
193-
from_port = local.https_port
194-
to_port = local.https_port
195-
ip_protocol = "tcp"
192+
193+
from_port = local.https_port
194+
to_port = local.https_port
195+
ip_protocol = "tcp"
196196
# make more restrictive
197-
cidr_ipv4 = local.cidr_anywhere
197+
cidr_ipv4 = local.cidr_anywhere
198198
}
199199

200200
/*
@@ -215,25 +215,25 @@ resource "aws_vpc_security_group_egress_rule" "comet_ec2_egress_any" {
215215
}
216216

217217
resource "aws_iam_role" "comet-ec2-s3-access-role" {
218-
name = "comet-ml-s3-role"
218+
name = "comet-ml-s3-role"
219219
assume_role_policy = jsonencode({
220-
"Version": "2012-10-17",
221-
"Statement": [
220+
"Version" : "2012-10-17",
221+
"Statement" : [
222222
{
223-
"Action": "sts:AssumeRole",
224-
"Principal": {
225-
"Service": "ec2.amazonaws.com"
223+
"Action" : "sts:AssumeRole",
224+
"Principal" : {
225+
"Service" : "ec2.amazonaws.com"
226226
},
227-
"Effect": "Allow",
228-
"Sid": ""
227+
"Effect" : "Allow",
228+
"Sid" : ""
229229
}
230230
]
231231
})
232232
}
233233

234234
resource "aws_iam_instance_profile" "comet-ec2-instance-profile" {
235-
name = "${var.environment}-comet-ec2-instance-profile"
236-
role = aws_iam_role.comet-ec2-s3-access-role.name
235+
name = "${var.environment}-comet-ec2-instance-profile"
236+
role = aws_iam_role.comet-ec2-s3-access-role.name
237237
}
238238

239239
resource "aws_iam_role_policy_attachment" "comet-ml-s3-access-attachment" {

comet-infrastructure/modules/comet_ec2_alb/main.tf

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ locals {
55
cidr_anywhere = "0.0.0.0/0"
66

77
tags = {
8-
Terraform = "true"
9-
Environment = var.environment
8+
Terraform = "true"
9+
Environment = var.environment
1010
}
1111
}
1212

@@ -18,26 +18,26 @@ resource "aws_security_group" "comet_alb_sg" {
1818

1919
resource "aws_vpc_security_group_ingress_rule" "comet_ec2_alb_http" {
2020
security_group_id = aws_security_group.comet_alb_sg.id
21-
21+
2222
from_port = local.http_port
2323
to_port = local.http_port
24-
ip_protocol = "tcp"
25-
cidr_ipv4 = local.cidr_anywhere
24+
ip_protocol = "tcp"
25+
cidr_ipv4 = local.cidr_anywhere
2626
}
2727

2828
resource "aws_vpc_security_group_ingress_rule" "comet_ec2_alb_https" {
2929
security_group_id = aws_security_group.comet_alb_sg.id
30-
30+
3131
from_port = local.https_port
3232
to_port = local.https_port
33-
ip_protocol = "tcp"
34-
cidr_ipv4 = local.cidr_anywhere
33+
ip_protocol = "tcp"
34+
cidr_ipv4 = local.cidr_anywhere
3535
}
3636

3737
resource "aws_vpc_security_group_egress_rule" "comet_ec2_alb_egress" {
3838
security_group_id = aws_security_group.comet_alb_sg.id
39-
ip_protocol = "-1"
40-
cidr_ipv4 = local.cidr_anywhere
39+
ip_protocol = "-1"
40+
cidr_ipv4 = local.cidr_anywhere
4141
}
4242

4343
module "alb" {
@@ -48,9 +48,9 @@ module "alb" {
4848

4949
load_balancer_type = "application"
5050

51-
vpc_id = var.vpc_id
52-
subnets = var.public_subnets
53-
security_groups = [aws_security_group.comet_alb_sg.id]
51+
vpc_id = var.vpc_id
52+
subnets = var.public_subnets
53+
security_groups = [aws_security_group.comet_alb_sg.id]
5454

5555
target_groups = [
5656
{
@@ -63,10 +63,10 @@ module "alb" {
6363

6464
https_listeners = [
6565
{
66-
port = 443
67-
protocol = "HTTPS"
68-
certificate_arn = var.ssl_certificate_arn
69-
target_group_index = 0
66+
port = 443
67+
protocol = "HTTPS"
68+
certificate_arn = var.ssl_certificate_arn
69+
target_group_index = 0
7070
}
7171
]
7272

comet-infrastructure/modules/comet_ec2_alb/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ variable "vpc_id" {
1212

1313
variable "public_subnets" {
1414
description = "Subnets specified for ALB"
15-
type = list
15+
type = list(any)
1616
}
1717

1818
variable "ssl_certificate_arn" {

comet-infrastructure/modules/comet_eks/main.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
locals {
22
tags = {
3-
Terraform = "true"
3+
Terraform = "true"
44
Environment = var.environment
55
}
66
}
@@ -16,11 +16,11 @@ module "eks" {
1616
cluster_name = var.eks_cluster_name
1717
cluster_version = var.eks_cluster_version
1818
cluster_endpoint_public_access = true
19-
19+
2020
vpc_id = var.vpc_id
2121
subnet_ids = var.eks_private_subnets
2222

23-
eks_managed_node_group_defaults = {ami_type = var.eks_mng_ami_type}
23+
eks_managed_node_group_defaults = { ami_type = var.eks_mng_ami_type }
2424

2525
eks_managed_node_groups = {
2626
one = {
@@ -30,7 +30,7 @@ module "eks" {
3030
max_size = var.eks_mng_max_size
3131
desired_size = var.eks_mng_desired_size
3232

33-
iam_role_additional_policies = var.s3_enabled ? {comet_s3_access = var.comet_ec2_s3_iam_policy} : {}
33+
iam_role_additional_policies = var.s3_enabled ? { comet_s3_access = var.comet_ec2_s3_iam_policy } : {}
3434
}
3535
}
3636

@@ -49,7 +49,7 @@ module "irsa-ebs-csi" {
4949
}
5050

5151
module "eks_blueprints_addons" {
52-
source = "aws-ia/eks-blueprints-addons/aws"
52+
source = "aws-ia/eks-blueprints-addons/aws"
5353
version = "0.2.0"
5454

5555
cluster_name = module.eks.cluster_name
@@ -61,9 +61,9 @@ module "eks_blueprints_addons" {
6161
coredns = {}
6262
vpc-cni = {}
6363
kube-proxy = {}
64-
aws-ebs-csi-driver = {service_account_role_arn = module.irsa-ebs-csi.iam_role_arn}
64+
aws-ebs-csi-driver = { service_account_role_arn = module.irsa-ebs-csi.iam_role_arn }
6565
}
66-
66+
6767
enable_aws_load_balancer_controller = var.eks_aws_load_balancer_controller
6868
enable_cert_manager = var.eks_cert_manager
6969
enable_aws_cloudwatch_metrics = var.eks_aws_cloudwatch_metrics

comet-infrastructure/modules/comet_eks/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ variable "s3_enabled" {
7777

7878
variable "comet_ec2_s3_iam_policy" {
7979
description = "Policy with access to S3 to associate with EKS worker nodes"
80-
type = string
81-
default = null
80+
type = string
81+
default = null
8282
}

comet-infrastructure/modules/comet_elasticache/main.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,25 @@ resource "aws_elasticache_cluster" "comet-ml-ec-redis" {
1616
engine_version = var.elasticache_engine_version
1717
port = local.redis_port
1818
subnet_group_name = aws_elasticache_subnet_group.comet-ml-ec-subnet-group.name
19-
security_group_ids = [aws_security_group.redis_inbound_sg.id]
19+
security_group_ids = [aws_security_group.redis_inbound_sg.id]
2020
}
2121

2222
resource "aws_elasticache_subnet_group" "comet-ml-ec-subnet-group" {
23-
name = "cometml-ec-sng-${var.environment}"
23+
name = "cometml-ec-sng-${var.environment}"
2424
subnet_ids = var.elasticache_private_subnets
2525
}
2626

2727
resource "aws_security_group" "redis_inbound_sg" {
2828
name = "cometml_redis_in_sg_${var.environment}"
2929
description = "Redis Security Group"
30-
vpc_id = var.vpc_id
30+
vpc_id = var.vpc_id
3131
}
3232

3333
resource "aws_vpc_security_group_ingress_rule" "redis_port_inbound_rule" {
3434
security_group_id = aws_security_group.redis_inbound_sg.id
3535

36-
from_port = local.redis_port
37-
to_port = local.redis_port
38-
ip_protocol = "tcp"
36+
from_port = local.redis_port
37+
to_port = local.redis_port
38+
ip_protocol = "tcp"
3939
referenced_security_group_id = var.elasticache_allow_from_sg
4040
}

0 commit comments

Comments
 (0)