Skip to content

Commit

Permalink
rollback deleted features
Browse files Browse the repository at this point in the history
  • Loading branch information
brunodasilvalenga committed Jun 25, 2024
1 parent 7131c67 commit 981e5a4
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 9 deletions.
63 changes: 62 additions & 1 deletion _variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ variable "port" {
description = "Port for target group to listen"
}

variable "ports" {
default = [
{
port = 80
protocol = "tcp"
}
]
description = "Port for target group to listen"
type = list(object({
port = number
protocol = string
}))
}

variable "container_port" {
default = "8080"
description = "Port your container listens (used in the placeholder task definition)"
Expand Down Expand Up @@ -129,7 +143,7 @@ variable "placement_constraints" {
}

variable "launch_type" {
default = "EC2"
default = "FARGATE"
description = "The launch type on which to run your service. The valid values are EC2 and FARGATE. Defaults to EC2."
}

Expand Down Expand Up @@ -202,3 +216,50 @@ variable "security_group_nlb_inbound_cidrs" {
default = ["0.0.0.0/0"]
description = "NLB inbound allowed CIDRs for the security group."
}

variable "create_iam_codedeployrole" {
type = bool
default = true
description = "Create Codedeploy IAM Role for ECS or not."
}

variable "codedeploy_role_arn" {
default = null
description = "Existing IAM CodeDeploy role ARN created by ECS cluster module"
}

variable "efs_mapping" {
type = map(string)
description = "A map of efs volume ids and paths to mount into the default task definition"
default = {}
}

variable "ulimits" {
type = list(object({
name = string
hardLimit = number
softLimit = number
}))
description = "Container ulimit settings. This is a list of maps, where each map should contain \"name\", \"hardLimit\" and \"softLimit\""
default = null
}

variable "deployment_controller" {
default = "CODE_DEPLOY"
description = "Type of deployment controller. Valid values: CODE_DEPLOY, ECS, EXTERNAL."
}

variable "codedeploy_wait_time_for_cutover" {
default = 0
description = "Time in minutes to route the traffic to the new application deployment"
}

variable "codedeploy_wait_time_for_termination" {
default = 0
description = "Time in minutes to terminate the new deployment"
}

variable "codedeploy_deployment_config_name" {
default = "CodeDeployDefault.ECSAllAtOnce"
description = "Specifies the deployment configuration for CodeDeploy"
}
20 changes: 12 additions & 8 deletions ecs-service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ resource "aws_ecs_service" "default" {
health_check_grace_period_seconds = var.service_health_check_grace_period_seconds
enable_execute_command = true

load_balancer {
target_group_arn = aws_lb_target_group.ecs_default_tcp.arn
container_name = var.name
container_port = var.container_port
dynamic "load_balancer" {
for_each = { for port in var.ports : port.port => port }
content {
target_group_arn = aws_lb_target_group.ecs_default_tcp[load_balancer.value.port].arn
container_name = var.name
container_port = load_balancer.value.port
}
}

dynamic "placement_constraints" {
Expand Down Expand Up @@ -65,11 +68,12 @@ resource "aws_security_group" "ecs_service" {


resource "aws_security_group_rule" "ecs_service_from_nlb" {
count = var.nlb ? 1 : 0
# for_each = var.nlb == true ? { for port in var.ports : port.port => port } : []
for_each = { for port in(var.nlb == true ? var.ports : []) : port.port => port }
type = "ingress"
from_port = var.port
to_port = var.port
protocol = "tcp"
from_port = each.value.port
to_port = each.value.port
protocol = each.value.protocol
security_group_id = aws_security_group.ecs_service.id
source_security_group_id = aws_security_group.nlb[0].id
}

0 comments on commit 981e5a4

Please sign in to comment.