Skip to content

Commit 027c23e

Browse files
committed
Add documentation and formatting to tfvars and cleanup s3 bucket name usage
1 parent 2d92cbe commit 027c23e

File tree

6 files changed

+116
-77
lines changed

6 files changed

+116
-77
lines changed

comet-infrastructure/main.tf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ data "aws_eks_cluster_auth" "this" {
55

66
locals {
77
resource_name = "comet-${var.environment}"
8-
9-
#set environment here, and use local.environment for the environment variables in all of the module calls
108
tags = {
119
Terraform = "true"
1210
Environment = var.environment
@@ -40,7 +38,6 @@ module "comet_ec2" {
4038
comet_ec2_alb_sg = var.enable_ec2_alb ? module.comet_ec2_alb[0].comet_alb_sg : null
4139

4240
s3_enabled = var.enable_s3
43-
comet_ml_s3_bucket = var.s3_bucket_name
4441
comet_ec2_s3_iam_policy = var.enable_s3 ? module.comet_s3[0].comet_s3_iam_policy_arn : null
4542
}
4643

comet-infrastructure/modules/comet_ec2/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ 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-
cidr_ipv4 = local.cidr_anywhere
176+
cidr_ipv4 = local.cidr_anywhere
177177
}
178178

179179
resource "aws_vpc_security_group_ingress_rule" "comet_ec2_ingress_http" {
@@ -182,7 +182,7 @@ resource "aws_vpc_security_group_ingress_rule" "comet_ec2_ingress_http" {
182182
from_port = local.http_port
183183
to_port = local.http_port
184184
ip_protocol = "tcp"
185-
cidr_ipv4 = local.cidr_anywhere
185+
cidr_ipv4 = local.cidr_anywhere
186186
}
187187

188188
resource "aws_vpc_security_group_ingress_rule" "comet_ec2_ingress_https" {
@@ -191,13 +191,13 @@ resource "aws_vpc_security_group_ingress_rule" "comet_ec2_ingress_https" {
191191
from_port = local.https_port
192192
to_port = local.https_port
193193
ip_protocol = "tcp"
194-
cidr_ipv4 = local.cidr_anywhere
194+
cidr_ipv4 = local.cidr_anywhere
195195
}
196196

197197
resource "aws_vpc_security_group_ingress_rule" "comet_ec2_alb_http" {
198198
count = var.alb_enabled ? 1 : 0
199199
security_group_id = aws_security_group.comet_ec2_sg.id
200-
200+
201201
from_port = local.http_port
202202
to_port = local.http_port
203203
ip_protocol = "tcp"

comet-infrastructure/modules/comet_ec2/variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ variable "comet_ec2_key" {
5656
type = string
5757
}
5858

59-
variable "comet_ml_s3_bucket" {
60-
description = "Name of the S3 bucket provisioned for Comet"
61-
type = string
62-
default = null
63-
}
64-
6559
variable "comet_ec2_s3_iam_policy" {
6660
description = "Policy granting access to Comet S3 bucket"
6761
type = string

comet-infrastructure/modules/comet_s3/variables.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
variable "environment" {
22
description = "Deployment environment, i.e. dev/stage/prod, etc"
33
type = string
4-
default = "dev"
54
}
65

76
variable "comet_s3_bucket" {

comet-infrastructure/terraform.tfvars

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,70 @@
1-
enable_vpc = false
2-
enable_ec2 = false
3-
enable_ec2_alb = false
4-
enable_eks = false
1+
########################
2+
#### Module toggles ####
3+
########################
4+
# Create a VPC to launch other resources in
5+
enable_vpc = false
6+
7+
# Create an EC2 instance for running Comet
8+
enable_ec2 = false
9+
10+
# Create an ALB for the Comet EC2 instance
11+
enable_ec2_alb = false
12+
13+
# Create an EKS cluster for running Comet
14+
enable_eks = false
15+
16+
# Create ElastiCache resources for running Comet Redis
517
enable_elasticache = false
6-
enable_rds = false
7-
enable_s3 = false
818

9-
region = "us-east-1"
19+
# Create RDS resources for running Comet MySQL
20+
enable_rds = false
21+
22+
# Create S3 resources for storing Comet objects
23+
enable_s3 = false
24+
25+
################
26+
#### Global ####
27+
################
28+
# Region to launch resources in
29+
region = "us-east-1"
30+
31+
# Name for Comet environment, for use in resource naming
1032
environment = "prod"
1133

12-
# if not using comet_vpc to provision a VPC for the Comet resources, set the variables below to specify the existing VPC
34+
# If not setting enable_vpc to provision a VPC for the Comet resources, set the variables below to specify the existing VPC in which resources will be launched
1335
comet_vpc_id = "vpc-012345abcdefghijkl"
1436
availability_zones = ["us-east-1a", "us-east-1b", "us-east-1c"]
1537
comet_public_subnets = ["subnet-012345abcdefghijkl", "subnet-012345abcdefghijkl", "subnet-012345abcdefghijkl"]
1638
comet_private_subnets = ["subnet-012345abcdefghijkl", "subnet-012345abcdefghijkl", "subnet-012345abcdefghijkl"]
1739

18-
# if provisioning comet_ec2_alb, specify the following for the HTTPS listener
19-
#ssl_certificate_arn = ""
40+
#######################
41+
#### Module inputs ####
42+
#######################
43+
## Required module inputs listed below. Any desired overrides from the defaults in variables.tf can also be added here
44+
45+
#### comet_ec2 ####
46+
#
47+
48+
#### comet_ec2_alb ####
49+
# If setting enable_ec2_alb, specify the ARN of an SSL certificate for the HTTPS listener
50+
ssl_certificate_arn = null
2051

21-
# if provisioning comet_elasticache for use with existing compute, set the variable below to specify an SG that connections will be allowed from
52+
#### comet_eks ####
53+
#
54+
55+
#### comet_elasticache ####
56+
# If setting enable_elasticache with existing compute, set the variable below to specify an SG that connections will be allowed from
2257
elasticache_allow_from_sg = "sg-012345abcdefghijkl"
2358

24-
# if provisioning comet_rds for use with existing compute, set the variable below to specify an SG that connections will be allowed from
59+
#### comet_rds ####
60+
# If setting enable_rds, specify the root password for RDS below, or leave null and enter at the prompt during apply
61+
rds_root_password = null
62+
# If setting enable_rds with existing compute, set the variable below to specify an SG that connections will be allowed from
2563
rds_allow_from_sg = "sg-012345abcdefghijkl"
2664

27-
s3_bucket_name = "comet-use2-bucket"
28-
rds_root_password = "CHANGE-ME"
65+
#### comet_s3 ####
66+
# If setting enable_s3, specify the bucket name below
67+
s3_bucket_name = null
68+
69+
#### comet_vpc ####
70+
#

comet-infrastructure/variables.tf

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,6 @@
1-
#global
2-
variable "environment" {
3-
description = "Deployment environment, i.e. dev/stage/prod, etc"
4-
type = string
5-
default = "dev"
6-
}
7-
8-
variable "region" {
9-
description = "AWS region to provision resources in"
10-
type = string
11-
}
12-
13-
variable "availability_zones" {
14-
description = "List of availability zones from region"
15-
type = list(string)
16-
default = null
17-
}
18-
19-
variable "comet_vpc_id" {
20-
description = "ID of an existing VPC to provision resources in"
21-
type = string
22-
default = null
23-
}
24-
25-
variable "comet_private_subnets" {
26-
description = "List of private subnets IDs from existing VPC to provision resources in"
27-
type = list(string)
28-
default = null
29-
}
30-
31-
variable "comet_public_subnets" {
32-
description = "List of public subnets IDs from existing VPC to provision resources in"
33-
type = list(string)
34-
default = null
35-
}
36-
37-
#child module toggles
1+
########################
2+
#### Module toggles ####
3+
########################
384
variable "enable_vpc" {
395
description = "Toggles the comet_vpc module, to provision a new VPC for hosting the Comet resources"
406
type = bool
@@ -70,14 +36,49 @@ variable "enable_s3" {
7036
type = bool
7137
}
7238

73-
#comet_vpc
74-
variable "single_nat_gateway" {
75-
description = "Controls whether single NAT gateway used for all public subnets"
76-
type = bool
77-
default = true
39+
################
40+
#### Global ####
41+
################
42+
variable "environment" {
43+
description = "Deployment environment, i.e. dev/stage/prod, etc"
44+
type = string
45+
default = "dev"
46+
}
47+
48+
variable "region" {
49+
description = "AWS region to provision resources in"
50+
type = string
51+
}
52+
53+
variable "availability_zones" {
54+
description = "List of availability zones from region"
55+
type = list(string)
56+
default = null
57+
}
58+
59+
variable "comet_vpc_id" {
60+
description = "ID of an existing VPC to provision resources in"
61+
type = string
62+
default = null
7863
}
7964

80-
#comet_ec2
65+
variable "comet_private_subnets" {
66+
description = "List of private subnets IDs from existing VPC to provision resources in"
67+
type = list(string)
68+
default = null
69+
}
70+
71+
variable "comet_public_subnets" {
72+
description = "List of public subnets IDs from existing VPC to provision resources in"
73+
type = list(string)
74+
default = null
75+
}
76+
77+
#######################
78+
#### Module inputs ####
79+
#######################
80+
81+
#### comet_ec2 ####
8182
variable "comet_ec2_ami_type" {
8283
type = string
8384
description = "Operating system type for the EC2 instance AMI"
@@ -118,14 +119,14 @@ variable "comet_ec2_key" {
118119
default = null
119120
}
120121

121-
#comet_ec2_alb
122+
#### comet_ec2_alb ####
122123
variable "ssl_certificate_arn" {
123124
description = "ARN of the ACM certificate to use for the ALB"
124125
type = string
125126
default = null
126127
}
127128

128-
#comet_eks
129+
#### comet_eks ####
129130
variable "eks_cluster_name" {
130131
description = "Name for EKS cluster"
131132
type = string
@@ -192,7 +193,7 @@ variable "eks_external_dns" {
192193
default = true
193194
}
194195

195-
#comet_elasticache
196+
#### comet_elasticache ####
196197
variable "elasticache_allow_from_sg" {
197198
description = "Security group from which to allow connections to ElastiCache, to use when provisioning with existing compute"
198199
type = string
@@ -229,7 +230,7 @@ variable "elasticache_num_cache_nodes" {
229230
default = 1
230231
}
231232

232-
#comet_rds
233+
#### comet_rds ####
233234
variable "rds_allow_from_sg" {
234235
description = "Security group from which to allow connections to RDS, to use when provisioning with existing compute"
235236
type = string
@@ -295,9 +296,15 @@ variable "rds_root_password" {
295296
type = string
296297
}
297298

298-
#comet_s3
299+
#### comet_s3 ####
299300
variable "s3_bucket_name" {
300301
description = "Name for S3 bucket"
301302
type = string
302-
default = ""
303+
}
304+
305+
#### comet_vpc ####
306+
variable "single_nat_gateway" {
307+
description = "Controls whether single NAT gateway used for all public subnets"
308+
type = bool
309+
default = true
303310
}

0 commit comments

Comments
 (0)