Skip to content

Commit

Permalink
Citadel/update release from 1.2.0 to 1.3.0 (#11)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
4 people authored Mar 18, 2022
1 parent 745eb44 commit 2d270f6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ In addition you have the option to create or not :
| Name | Version |
|------|---------|
| aws | n/a |
| random | n/a |

## Inputs

Expand All @@ -66,6 +67,8 @@ In addition you have the option to create or not :
| autoscaling\_scale\_in\_cooldown | Cooldown in seconds to wait between scale in events | `number` | `300` | no |
| autoscaling\_scale\_out\_cooldown | Cooldown in seconds to wait between scale out events | `number` | `300` | no |
| autoscaling\_target\_cpu | Target average CPU percentage to track for autoscaling | `number` | `50` | no |
| 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 |
| 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 |
| cluster\_name | n/a | `string` | `"Name of existing ECS Cluster to deploy this app to"` | no |
| container\_port | Port your container listens (used in the placeholder task definition) | `string` | `"8080"` | no |
| cpu | Hard limit for CPU for the container | `string` | `"0"` | no |
Expand All @@ -78,6 +81,7 @@ In addition you have the option to create or not :
| memory | Hard memory of the container | `string` | `"512"` | no |
| name | Name of your ECS service | `any` | n/a | yes |
| 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 |
| nlb | Flag to create the NLB | `bool` | `false` | no |
| nlb\_arn | Networking LoadBalance ARN - Required if nlb=false or nlb\_internal=false | `string` | `""` | no |
| nlb\_internal | Creates an Internal NLB for this service | `bool` | `false` | no |
| 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 |
Expand Down
1 change: 0 additions & 1 deletion _variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ variable "service_health_check_grace_period_seconds" {
description = "Time until your container starts serving requests"
}


variable "ordered_placement_strategy" {
# This variable may not be used with Fargate!
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."
Expand Down
10 changes: 8 additions & 2 deletions nlb-target-group.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "aws_lb_listener" "ecs_tcp" {
load_balancer_arn = var.nlb ? aws_lb.default[0].arn : var.nlb_arn
load_balancer_arn = var.nlb ? try(aws_lb.default[0].arn, "") : var.nlb_arn
port = var.port
protocol = "TCP"

Expand All @@ -9,8 +9,14 @@ resource "aws_lb_listener" "ecs_tcp" {
}
}

resource "random_string" "tg_nlb_prefix" {
length = 4
upper = false
special = false
}

resource "aws_lb_target_group" "ecs_default_tcp" {
name = "ecs-${var.cluster_name}-${var.name}-tcp"
name = format("%s-%s-tcp", substr("${var.cluster_name}-${var.name}", 0, 23), random_string.tg_nlb_prefix.result)
port = var.port
protocol = "TCP"
vpc_id = var.vpc_id
Expand Down
8 changes: 7 additions & 1 deletion nlb.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
resource "random_string" "nlb_prefix" {
length = 4
upper = false
special = false
}

resource "aws_lb" "default" {
count = var.nlb ? 1 : 0
name = var.nlb_internal ? "ecs-${var.cluster_name}-${var.name}-internal" : "ecs-${var.cluster_name}-${var.name}"
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)
internal = var.nlb_internal
load_balancer_type = "network"
subnets = var.subnets
Expand Down
2 changes: 1 addition & 1 deletion route53-record.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ resource "aws_route53_record" "hostname" {
name = var.hostname
type = "CNAME"
ttl = "300"
records = var.nlb_internal ? [aws_lb.default[0].dns_name] : [data.aws_lb.nlb_selected[0].dns_name]
records = var.nlb_internal ? [aws_lb.default[0].dns_name] : [try(data.aws_lb.nlb_selected[0].dns_name, "")]
}

0 comments on commit 2d270f6

Please sign in to comment.