Skip to content

Commit 2d270f6

Browse files
soaresedsadenot
andauthored
Citadel/update release from 1.2.0 to 1.3.0 (#11)
* Updating files nlb-internal.tf nlb-target-group.tf with correct Variable to match with Citadel Infra and Parameter according to AWS prerequisites for NLB, remove nlb.tf it's a null file and variable * Updating files nlb-internal.tf nlb-target-group.tf with correct Variable to match with Citadel Infra and Parameter according to AWS prerequisites for NLB, remove nlb.tf it's a null file and variable * terraform-docs: automated update action * Solving limitation of '32 characters' in 'name' variables for NLB * terraform-docs: automated update action * Change '-tcp' to '-int' in nlb-internal.tf * Removing duplicated internal string * Adding nlb parameter back for compability and fixing route53 missing argument * terraform-docs: automated update action Co-authored-by: edson.siqueira@dnx.solutions <Edson Soares Siqueira> Co-authored-by: soareseds <soareseds@users.noreply.github.com> Co-authored-by: Allan Denot <adenot@gmail.com> Co-authored-by: adenot <adenot@users.noreply.github.com>
1 parent 745eb44 commit 2d270f6

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ In addition you have the option to create or not :
5252
| Name | Version |
5353
|------|---------|
5454
| aws | n/a |
55+
| random | n/a |
5556

5657
## Inputs
5758

@@ -66,6 +67,8 @@ In addition you have the option to create or not :
6667
| autoscaling\_scale\_in\_cooldown | Cooldown in seconds to wait between scale in events | `number` | `300` | no |
6768
| autoscaling\_scale\_out\_cooldown | Cooldown in seconds to wait between scale out events | `number` | `300` | no |
6869
| autoscaling\_target\_cpu | Target average CPU percentage to track for autoscaling | `number` | `50` | no |
70+
| cloudwatch\_logs\_export | Whether to mark the log group to export to an S3 bucket (needs terraform-aws-log-exporter to be deployed in the account/region) | `bool` | `false` | no |
71+
| cloudwatch\_logs\_retention | Specifies the number of days you want to retain log events in the specified log group. Possible values are: 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, and 3653. | `number` | `120` | no |
6972
| cluster\_name | n/a | `string` | `"Name of existing ECS Cluster to deploy this app to"` | no |
7073
| container\_port | Port your container listens (used in the placeholder task definition) | `string` | `"8080"` | no |
7174
| cpu | Hard limit for CPU for the container | `string` | `"0"` | no |
@@ -78,6 +81,7 @@ In addition you have the option to create or not :
7881
| memory | Hard memory of the container | `string` | `"512"` | no |
7982
| name | Name of your ECS service | `any` | n/a | yes |
8083
| network\_mode | 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) | `any` | `null` | no |
84+
| nlb | Flag to create the NLB | `bool` | `false` | no |
8185
| nlb\_arn | Networking LoadBalance ARN - Required if nlb=false or nlb\_internal=false | `string` | `""` | no |
8286
| nlb\_internal | Creates an Internal NLB for this service | `bool` | `false` | no |
8387
| 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 |

_variables.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ variable "service_health_check_grace_period_seconds" {
108108
description = "Time until your container starts serving requests"
109109
}
110110

111-
112111
variable "ordered_placement_strategy" {
113112
# This variable may not be used with Fargate!
114113
description = "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."

nlb-target-group.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_lb_listener" "ecs_tcp" {
2-
load_balancer_arn = var.nlb ? aws_lb.default[0].arn : var.nlb_arn
2+
load_balancer_arn = var.nlb ? try(aws_lb.default[0].arn, "") : var.nlb_arn
33
port = var.port
44
protocol = "TCP"
55

@@ -9,8 +9,14 @@ resource "aws_lb_listener" "ecs_tcp" {
99
}
1010
}
1111

12+
resource "random_string" "tg_nlb_prefix" {
13+
length = 4
14+
upper = false
15+
special = false
16+
}
17+
1218
resource "aws_lb_target_group" "ecs_default_tcp" {
13-
name = "ecs-${var.cluster_name}-${var.name}-tcp"
19+
name = format("%s-%s-tcp", substr("${var.cluster_name}-${var.name}", 0, 23), random_string.tg_nlb_prefix.result)
1420
port = var.port
1521
protocol = "TCP"
1622
vpc_id = var.vpc_id

nlb.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
resource "random_string" "nlb_prefix" {
2+
length = 4
3+
upper = false
4+
special = false
5+
}
6+
17
resource "aws_lb" "default" {
28
count = var.nlb ? 1 : 0
3-
name = var.nlb_internal ? "ecs-${var.cluster_name}-${var.name}-internal" : "ecs-${var.cluster_name}-${var.name}"
9+
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)
410
internal = var.nlb_internal
511
load_balancer_type = "network"
612
subnets = var.subnets

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] : [data.aws_lb.nlb_selected[0].dns_name]
13+
records = var.nlb_internal ? [aws_lb.default[0].dns_name] : [try(data.aws_lb.nlb_selected[0].dns_name, "")]
1414
}

0 commit comments

Comments
 (0)