Skip to content

DT-436 old eks module #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 81 additions & 87 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ data "aws_eks_cluster_auth" "this" {

locals {
resource_name = "comet-${var.environment}"
tags = {
Terraform = "true"
Environment = var.environment
}
all_tags = merge(
{
Terraform = "true"
Environment = var.environment_tag
},
var.common_tags
)
}

module "comet_vpc" {
source = "./modules/comet_vpc"
count = var.enable_vpc ? 1 : 0
environment = var.environment
common_tags = local.all_tags
region = var.region

eks_enabled = var.enable_eks
Expand All @@ -25,6 +29,7 @@ module "comet_ec2" {
source = "./modules/comet_ec2"
count = var.enable_ec2 ? 1 : 0
environment = var.environment
common_tags = local.all_tags

vpc_id = var.enable_vpc ? module.comet_vpc[0].vpc_id : var.comet_vpc_id
comet_ec2_subnet = var.enable_vpc ? module.comet_vpc[0].public_subnets[0] : var.comet_public_subnets[0]
Expand All @@ -47,6 +52,7 @@ module "comet_ec2_alb" {
source = "./modules/comet_ec2_alb"
count = var.enable_ec2_alb ? 1 : 0
environment = var.environment
common_tags = local.all_tags

vpc_id = var.enable_vpc ? module.comet_vpc[0].vpc_id : var.comet_vpc_id
public_subnets = var.enable_vpc ? module.comet_vpc[0].public_subnets : var.comet_public_subnets
Expand All @@ -57,6 +63,7 @@ module "comet_eks" {
source = "./modules/comet_eks"
count = var.enable_eks ? 1 : 0
environment = var.environment
common_tags = local.all_tags

vpc_id = var.enable_vpc ? module.comet_vpc[0].vpc_id : var.comet_vpc_id
eks_private_subnets = var.enable_vpc ? module.comet_vpc[0].private_subnets : var.comet_private_subnets
Expand Down Expand Up @@ -89,6 +96,7 @@ module "comet_elasticache" {
source = "./modules/comet_elasticache"
count = var.enable_elasticache ? 1 : 0
environment = var.environment
common_tags = local.all_tags

vpc_id = var.enable_vpc ? module.comet_vpc[0].vpc_id : var.comet_vpc_id
elasticache_private_subnets = var.enable_vpc ? module.comet_vpc[0].private_subnets : var.comet_private_subnets
Expand All @@ -108,6 +116,7 @@ module "comet_rds" {
source = "./modules/comet_rds"
count = var.enable_rds ? 1 : 0
environment = var.environment
common_tags = local.all_tags

availability_zones = var.enable_vpc ? module.comet_vpc[0].azs : var.availability_zones
vpc_id = var.enable_vpc ? module.comet_vpc[0].vpc_id : var.comet_vpc_id
Expand All @@ -131,6 +140,7 @@ module "comet_s3" {
source = "./modules/comet_s3"
count = var.enable_s3 ? 1 : 0
environment = var.environment
common_tags = local.all_tags

comet_s3_bucket = var.s3_bucket_name
s3_force_destroy = var.s3_force_destroy
Expand Down
18 changes: 8 additions & 10 deletions modules/comet_ec2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ locals {
https_port = 443
any_port = 0
cidr_anywhere = "0.0.0.0/0"

tags = {
Terraform = "true"
Environment = var.environment
}
}

data "aws_ami" "al2" {
Expand Down Expand Up @@ -145,12 +140,16 @@ resource "aws_instance" "comet_ec2" {
root_block_device {
volume_type = var.comet_ec2_volume_type
volume_size = var.comet_ec2_volume_size
tags = var.common_tags
}

tags = merge(local.tags, {
Name = "${var.environment}-comet-ml-${count.index}"
})

tags = merge(
var.common_tags,
{
Name = "${var.environment}-comet-ml-${count.index}"
}
)

lifecycle {
create_before_destroy = true
}
Expand All @@ -161,7 +160,6 @@ resource "aws_eip" "comet_ec2_eip" {
instance = aws_instance.comet_ec2[0].id
domain = "vpc"
}

resource "aws_security_group" "comet_ec2_sg" {
name = "comet_${var.environment}_ec2_sg"
description = "Comet EC2 instance security group"
Expand Down
8 changes: 7 additions & 1 deletion modules/comet_ec2/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,10 @@ variable "comet_ec2_s3_iam_policy" {
variable "comet_ec2_alb_sg" {
description = "ID of the security group attached to an associated application load balancer, for creating ingress EC2 SG rule"
type = string
}
}

variable "common_tags" {
type = map(string)
description = "A map of common tags"
default = {}
}
8 changes: 1 addition & 7 deletions modules/comet_ec2_alb/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ locals {
https_port = 443
any_port = 0
cidr_anywhere = "0.0.0.0/0"

tags = {
Terraform = "true"
Environment = var.environment
}
}

resource "aws_security_group" "comet_alb_sg" {
Expand Down Expand Up @@ -43,6 +38,7 @@ resource "aws_vpc_security_group_egress_rule" "comet_ec2_alb_egress" {
module "alb" {
source = "terraform-aws-modules/alb/aws"
version = "~> 8.0"
tags = var.common_tags

name = "comet-${var.environment}-alb"

Expand Down Expand Up @@ -82,6 +78,4 @@ module "alb" {
}
}
]

tags = local.tags
}
8 changes: 7 additions & 1 deletion modules/comet_ec2_alb/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ variable "public_subnets" {
variable "ssl_certificate_arn" {
description = "ARN of the ACM certificate to use for the ALB"
type = string
}
}

variable "common_tags" {
type = map(string)
description = "A map of common tags"
default = {}
}
Loading