Skip to content

Commit 4e6cbe7

Browse files
committed
Sync from management repo
1 parent 3663fe0 commit 4e6cbe7

File tree

13 files changed

+97
-235
lines changed

13 files changed

+97
-235
lines changed

.github/workflows/stale-actions.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.64.0
3+
rev: v1.76.0
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_tflint
@@ -12,14 +12,13 @@ repos:
1212
- '--args=--only=terraform_documented_outputs'
1313
- '--args=--only=terraform_documented_variables'
1414
- '--args=--only=terraform_typed_variables'
15-
#- '--args=--only=terraform_module_pinned_source'
1615
- '--args=--only=terraform_naming_convention'
1716
- '--args=--only=terraform_required_providers'
1817
- '--args=--only=terraform_standard_module_structure'
1918
- '--args=--only=terraform_workspace_remote'
2019

2120
- repo: https://github.com/pre-commit/pre-commit-hooks
22-
rev: v4.1.0
21+
rev: v4.3.0
2322
hooks:
2423
- id: trailing-whitespace
2524
- id: end-of-file-fixer
@@ -31,7 +30,7 @@ repos:
3130
- id: requirements-txt-fixer
3231

3332
- repo: https://github.com/bridgecrewio/checkov.git
34-
rev: '2.0.914'
33+
rev: '2.1.280'
3534
hooks:
3635
- id: checkov
3736
verbose: true

README.md

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
### Versions
1919

2020
- Module tested for Terraform 1.0.1.
21-
- AWS provider version [3.74](https://registry.terraform.io/providers/hashicorp/aws/latest)
21+
- AWS provider version [4.35](https://registry.terraform.io/providers/hashicorp/aws/latest)
2222
- `main` branch: Provider versions not pinned to keep up with Terraform releases.
2323
- `tags` releases: Tags are pinned with versions (use <a href="https://github.com/tomarv2/terraform-aws-target-group/tags" alt="GitHub tag">
2424
<img src="https://img.shields.io/github/v/tag/tomarv2/terraform-aws-target-group" /></a> ).
@@ -111,53 +111,25 @@ Please refer to examples directory [link](examples) for references.
111111
<!-- BEGIN_TF_DOCS -->
112112
## Requirements
113113

114-
| Name | Version |
115-
|------|---------|
116-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.1 |
117-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 3.74 |
114+
No requirements.
118115

119116
## Providers
120117

121-
| Name | Version |
122-
|------|---------|
123-
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 3.74 |
118+
No providers.
124119

125120
## Modules
126121

127-
| Name | Source | Version |
128-
|------|--------|---------|
129-
| <a name="module_global"></a> [global](#module\_global) | git::git@github.com:tomarv2/terraform-global.git//aws | v0.0.1 |
122+
No modules.
130123

131124
## Resources
132125

133-
| Name | Type |
134-
|------|------|
135-
| [aws_lb_target_group.target_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_target_group) | resource |
136-
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
137-
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
126+
No resources.
138127

139128
## Inputs
140129

141-
| Name | Description | Type | Default | Required |
142-
|------|-------------|------|---------|:--------:|
143-
| <a name="input_deploy_target_group"></a> [deploy\_target\_group](#input\_deploy\_target\_group) | Feature flag, true or false | `bool` | `true` | no |
144-
| <a name="input_deregistration_delay"></a> [deregistration\_delay](#input\_deregistration\_delay) | deregistration delay | `string` | `"300"` | no |
145-
| <a name="input_healthcheck_interval"></a> [healthcheck\_interval](#input\_healthcheck\_interval) | health check interval | `string` | `""` | no |
146-
| <a name="input_healthcheck_matcher"></a> [healthcheck\_matcher](#input\_healthcheck\_matcher) | healthcheck matcher (e.g. 200) | `string` | `""` | no |
147-
| <a name="input_healthcheck_path"></a> [healthcheck\_path](#input\_healthcheck\_path) | target group health check path | `string` | `""` | no |
148-
| <a name="input_healthcheck_timeout"></a> [healthcheck\_timeout](#input\_healthcheck\_timeout) | health check timeout | `string` | `""` | no |
149-
| <a name="input_healthy_threshold"></a> [healthy\_threshold](#input\_healthy\_threshold) | target group health check threshold | `string` | `""` | no |
150-
| <a name="input_lb_port"></a> [lb\_port](#input\_lb\_port) | load balancer port | `list(any)` | <pre>[<br> 80<br>]</pre> | no |
151-
| <a name="input_lb_protocol"></a> [lb\_protocol](#input\_lb\_protocol) | load balancer protocol | `string` | `"HTTP"` | no |
152-
| <a name="input_prjid"></a> [prjid](#input\_prjid) | Name of the project/stack e.g: mystack, nifieks, demoaci. Should not be changed after running 'tf apply' | `string` | n/a | yes |
153-
| <a name="input_stickiness"></a> [stickiness](#input\_stickiness) | Target group sticky configuration | <pre>object({<br> cookie_duration = number<br> enabled = bool<br> })</pre> | `null` | no |
154-
| <a name="input_target_type"></a> [target\_type](#input\_target\_type) | target type | `string` | `"instance"` | no |
155-
| <a name="input_teamid"></a> [teamid](#input\_teamid) | Name of the team/group e.g. devops, dataengineering. Should not be changed after running 'tf apply' | `string` | n/a | yes |
156-
| <a name="input_unhealthy_threshold"></a> [unhealthy\_threshold](#input\_unhealthy\_threshold) | target group unhealthy health check threshold | `string` | `""` | no |
130+
No inputs.
157131

158132
## Outputs
159133

160-
| Name | Description |
161-
|------|-------------|
162-
| <a name="output_target_group_arn"></a> [target\_group\_arn](#output\_target\_group\_arn) | Target group arn |
134+
No outputs.
163135
<!-- END_TF_DOCS -->

examples/main.tf

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
terraform {
2+
required_version = ">= 1.0.1"
3+
required_providers {
4+
aws = {
5+
version = "~> 4.35"
6+
}
7+
}
8+
}
9+
10+
provider "aws" {
11+
region = var.region
12+
}
13+
14+
module "target_group" {
15+
source = "../"
16+
17+
config = {
18+
demotg = {
19+
protocol = "HTTP"
20+
port = 80
21+
healthcheck_path = "/"
22+
healthy_threshold = "2"
23+
healthcheck_matcher = "200"
24+
healthcheck_timeout = "15"
25+
unhealthy_threshold = "3"
26+
healthcheck_interval = "30"
27+
}
28+
demotg1 = {
29+
protocol = "HTTP"
30+
port = 80
31+
healthcheck_path = "/"
32+
healthy_threshold = "2"
33+
healthcheck_matcher = "200"
34+
healthcheck_timeout = "15"
35+
unhealthy_threshold = "3"
36+
healthcheck_interval = "30"
37+
}
38+
}
39+
teamid = var.teamid
40+
prjid = var.prjid
41+
}

examples/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "target_group_arn" {
2+
description = "Target group ARN"
3+
value = module.target_group.arn
4+
}

examples/sample/main.tf

Lines changed: 0 additions & 29 deletions
This file was deleted.

examples/sample/outputs.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/sample/variables.tf renamed to examples/variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
variable "teamid" {
22
description = "Name of the team/group e.g. devops, dataengineering. Should not be changed after running 'tf apply'"
33
type = string
4+
default = "demo"
45
}
56

67
variable "prjid" {
78
description = "Name of the project/stack e.g: mystack, nifieks, demoaci. Should not be changed after running 'tf apply'"
89
type = string
10+
default = "project"
911
}
1012

1113
variable "region" {

main.tf

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,30 @@
1-
# target group
2-
# https://github.com/cloudposse/terraform-aws-alb-ingress/issues/24
31
resource "aws_lb_target_group" "target_group" {
4-
count = var.deploy_target_group != false ? length(var.lb_port) : 0
2+
for_each = var.config
53

6-
7-
name = "${var.teamid}-${var.prjid}-${var.lb_port[count.index]}"
8-
port = element(var.lb_port, count.index)
9-
protocol = var.lb_protocol
10-
11-
vpc_id = module.global.vpc[local.account_id][local.region]
12-
tags = merge(local.shared_tags)
13-
14-
deregistration_delay = var.deregistration_delay
15-
target_type = var.target_type
4+
name = each.key
5+
port = each.value.port
6+
protocol = each.value.protocol
7+
vpc_id = try(each.value.vpc_id, module.global.vpc[local.account_id][local.region])
8+
tags = merge(local.shared_tags, var.extra_tags)
9+
deregistration_delay = try(each.value.deregistration_delay, "300")
10+
target_type = try(each.value.target_type, "instance")
1611

1712
health_check {
18-
interval = var.healthcheck_interval == "" ? null : var.healthcheck_interval
19-
path = var.healthcheck_path == "" ? null : var.healthcheck_path
20-
healthy_threshold = var.healthy_threshold == "" ? null : var.healthy_threshold
21-
unhealthy_threshold = var.unhealthy_threshold == "" ? null : var.unhealthy_threshold
22-
timeout = var.healthcheck_timeout == "" ? null : var.healthcheck_timeout
23-
protocol = var.lb_protocol == "" ? null : var.lb_protocol
24-
matcher = var.healthcheck_matcher == "" ? null : var.healthcheck_matcher
13+
interval = try(each.value.healthcheck_interval, null)
14+
path = try(each.value.healthcheck_path, null)
15+
healthy_threshold = try(each.value.healthy_threshold, null)
16+
unhealthy_threshold = try(each.value.unhealthy_threshold, null)
17+
timeout = try(each.value.healthcheck_timeout, null)
18+
protocol = try(each.value.lb_protoco, null)
19+
matcher = try(each.value.healthcheck_matcher, null)
2520
}
2621

2722
dynamic "stickiness" {
28-
for_each = var.stickiness == null ? [] : [var.stickiness]
23+
for_each = try(each.value.stickiness, null) == null ? [] : [each.value.stickiness]
2924
content {
3025
type = "lb_cookie"
3126
cookie_duration = stickiness.value.cookie_duration
32-
enabled = var.lb_protocol == "TCP" ? false : stickiness.value.enabled
27+
enabled = try(each.value.protocol, null) == "TCP" ? false : stickiness.value.enabled
3328
}
3429
}
3530
}

outputs.tf

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
output "target_group_arn" {
2-
description = "Target group arn"
3-
value = aws_lb_target_group.target_group.*.arn
1+
output "arn" {
2+
description = "Target group ARN"
3+
value = [for target_group in aws_lb_target_group.target_group : target_group.arn]
44
}
5+
6+
output "port" {
7+
description = "Target group port"
8+
value = [for target_group in aws_lb_target_group.target_group : target_group.port]
9+
}
10+
output "config" {
11+
description = "Target group configuration"
12+
value = aws_lb_target_group.target_group
13+
}

0 commit comments

Comments
 (0)