Skip to content

Commit 73eb90d

Browse files
Merge pull request #13 from DNXLabs/feature/improvements
Feature/improvements
2 parents 2d270f6 + ddba21e commit 73eb90d

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,12 @@ In addition you have the option to create or not :
8484
| nlb | Flag to create the NLB | `bool` | `false` | no |
8585
| nlb\_arn | Networking LoadBalance ARN - Required if nlb=false or nlb\_internal=false | `string` | `""` | no |
8686
| nlb\_internal | Creates an Internal NLB for this service | `bool` | `false` | no |
87+
| nlb\_subnets\_cidr | The subnets associated with the task or service. (REQUIRED IF 'LAUCH\_TYPE' IS FARGATE) | `any` | `null` | no |
88+
| nlb\_subnets\_ids | The subnets associated with the task or service. (REQUIRED IF 'LAUCH\_TYPE' IS FARGATE) | `any` | `null` | no |
8789
| ordered\_placement\_strategy | Service level strategy rules that are taken into consideration during task placement. List from top to bottom in order of precedence. The maximum number of ordered\_placement\_strategy blocks is 5. | <pre>list(object({<br> field = string<br> expression = string<br> }))</pre> | `[]` | no |
8890
| placement\_constraints | Rules that are taken into consideration during task placement. Maximum number of placement\_constraints is 10. | <pre>list(object({<br> type = string<br> expression = string<br> }))</pre> | `[]` | no |
8991
| port | Port for target group to listen | `string` | `"80"` | no |
92+
| security\_group\_ecs\_nodes\_inbound\_cidrs | ECS Nodes inbound allowed CIDRs for the security group. | `list(string)` | <pre>[<br> "0.0.0.0/0"<br>]</pre> | no |
9093
| security\_groups | The security groups associated with the task or service | `any` | `null` | no |
9194
| service\_health\_check\_grace\_period\_seconds | Time until your container starts serving requests | `number` | `0` | no |
9295
| service\_role\_arn | Existing service role ARN created by ECS cluster module | `any` | n/a | yes |

_variables.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,16 @@ variable "subnets" {
143143
description = "The subnets associated with the task or service. (REQUIRED IF 'LAUCH_TYPE' IS FARGATE)"
144144
}
145145

146+
variable "nlb_subnets_ids" {
147+
default = null
148+
description = "The subnets associated with the task or service. (REQUIRED IF 'LAUCH_TYPE' IS FARGATE)"
149+
}
150+
151+
variable "nlb_subnets_cidr" {
152+
default = null
153+
description = "The subnets associated with the task or service. (REQUIRED IF 'LAUCH_TYPE' IS FARGATE)"
154+
}
155+
146156
variable "network_mode" {
147157
default = null
148158
description = "The Docker networking mode to use for the containers in the task. The valid values are none, bridge, awsvpc, and host. (REQUIRED IF 'LAUCH_TYPE' IS FARGATE)"
@@ -179,4 +189,10 @@ variable "cloudwatch_logs_retention" {
179189
variable "cloudwatch_logs_export" {
180190
default = false
181191
description = "Whether to mark the log group to export to an S3 bucket (needs terraform-aws-log-exporter to be deployed in the account/region)"
192+
}
193+
194+
variable "security_group_ecs_nodes_inbound_cidrs" {
195+
type = list(string)
196+
default = ["0.0.0.0/0"]
197+
description = "ECS Nodes inbound allowed CIDRs for the security group."
182198
}

nlb.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ resource "aws_lb" "default" {
99
name = var.nlb_internal ? format("%s-%s-int", substr("${var.cluster_name}-${var.name}", 0, 23), random_string.nlb_prefix.result) : format("%s-%s", substr("${var.cluster_name}-${var.name}", 0, 27), random_string.nlb_prefix.result)
1010
internal = var.nlb_internal
1111
load_balancer_type = "network"
12-
subnets = var.subnets
12+
subnets = var.nlb_subnets_ids
1313
}

route53-record.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ resource "aws_route53_record" "hostname" {
1010
name = var.hostname
1111
type = "CNAME"
1212
ttl = "300"
13-
records = var.nlb_internal ? [aws_lb.default[0].dns_name] : [try(data.aws_lb.nlb_selected[0].dns_name, "")]
13+
records = [aws_lb.default[0].dns_name]
1414
}

sg-nodes.tf

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ data "aws_security_group" "selected" {
55
}
66
}
77

8+
resource "aws_security_group_rule" "vpc_from_nlb_to_ecs_nodes" {
9+
description = "From NLB subnet"
10+
type = "ingress"
11+
from_port = 0
12+
to_port = 65535
13+
protocol = "TCP"
14+
security_group_id = data.aws_security_group.selected.id
15+
cidr_blocks = var.nlb_subnets_cidr
16+
}
17+
818

919
resource "aws_security_group_rule" "all_from_nlb_to_ecs_nodes" {
1020
description = "for NLB"
@@ -13,5 +23,5 @@ resource "aws_security_group_rule" "all_from_nlb_to_ecs_nodes" {
1323
to_port = 65535
1424
protocol = "TCP"
1525
security_group_id = data.aws_security_group.selected.id
16-
cidr_blocks = ["0.0.0.0/0"]
26+
cidr_blocks = var.security_group_ecs_nodes_inbound_cidrs
1727
}

0 commit comments

Comments
 (0)