Skip to content

Commit

Permalink
Allow customizing the default target group name, target type, and tags (
Browse files Browse the repository at this point in the history
#29)

* Allow for specifying default target group name, type and tags

* Update documentation

* Revert "Update documentation"

This reverts commit c48f854.

* Update documentation (hopefully) properly

* Merge additional target group tags with label tags
  • Loading branch information
stangles authored and aknysh committed Oct 18, 2019
1 parent b662919 commit f96dc18
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ Available targets:
| stage | Stage, e.g. `prod`, `staging`, `dev`, or `test` | string | - | yes |
| subnet_ids | A list of subnet IDs to associate with ALB | list | - | yes |
| tags | Additional tags (e.g. `map(`BusinessUnit`,`XYZ`) | map | `<map>` | no |
| target_group_additional_tags | The additional tags to apply to the target group | map | `<map>` | no |
| target_group_name | The name for the default target group, uses a module label name if left empty | string | `` | no |
| target_group_port | The port for the default target group | string | `80` | no |
| target_group_target_type | The type (instance, ip or lambda) of targets that can be registered with the target group | string | `ip` | no |
| vpc_id | VPC ID to associate with ALB | string | - | yes |

## Outputs
Expand Down Expand Up @@ -276,13 +279,13 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
|---|---|---|---|

[osterman_homepage]: https://github.com/osterman
[osterman_avatar]: https://github.com/osterman.png?size=150
[osterman_avatar]: https://img.cloudposse.com/150x150/https://github.com/osterman.png
[goruha_homepage]: https://github.com/goruha
[goruha_avatar]: https://github.com/goruha.png?size=150
[goruha_avatar]: https://img.cloudposse.com/150x150/https://github.com/goruha.png
[aknysh_homepage]: https://github.com/aknysh
[aknysh_avatar]: https://github.com/aknysh.png?size=150
[aknysh_avatar]: https://img.cloudposse.com/150x150/https://github.com/aknysh.png
[sarkis_homepage]: https://github.com/sarkis
[sarkis_avatar]: https://github.com/sarkis.png?size=150
[sarkis_avatar]: https://img.cloudposse.com/150x150/https://github.com/sarkis.png



Expand Down
3 changes: 3 additions & 0 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
| stage | Stage, e.g. `prod`, `staging`, `dev`, or `test` | string | - | yes |
| subnet_ids | A list of subnet IDs to associate with ALB | list | - | yes |
| tags | Additional tags (e.g. `map(`BusinessUnit`,`XYZ`) | map | `<map>` | no |
| target_group_additional_tags | The additional tags to apply to the target group | map | `<map>` | no |
| target_group_name | The name for the default target group, uses a module label name if left empty | string | `` | no |
| target_group_port | The port for the default target group | string | `80` | no |
| target_group_target_type | The type (instance, ip or lambda) of targets that can be registered with the target group | string | `ip` | no |
| vpc_id | VPC ID to associate with ALB | string | - | yes |

## Outputs
Expand Down
6 changes: 4 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ module "default_target_group_label" {
}

resource "aws_lb_target_group" "default" {
name = "${module.default_target_group_label.id}"
name = "${var.target_group_name == "" ? module.default_target_group_label.id : var.target_group_name}"
port = "${var.target_group_port}"
protocol = "HTTP"
vpc_id = "${var.vpc_id}"
target_type = "ip"
target_type = "${var.target_group_target_type}"
deregistration_delay = "${var.deregistration_delay}"

health_check {
Expand All @@ -108,6 +108,8 @@ resource "aws_lb_target_group" "default" {
lifecycle {
create_before_destroy = true
}

tags = "${merge(module.default_target_group_label.tags, var.target_group_additional_tags)}"
}

resource "aws_lb_listener" "http" {
Expand Down
18 changes: 18 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,21 @@ variable "target_group_port" {
description = "The port for the default target group"
default = "80"
}

variable "target_group_name" {
type = "string"
default = ""
description = "The name for the default target group, uses a module label name if left empty"
}

variable "target_group_target_type" {
type = "string"
default = "ip"
description = "The type (instance, ip or lambda) of targets that can be registered with the target group"
}

variable "target_group_additional_tags" {
type = "map"
default = {}
description = "The additional tags to apply to the target group"
}

0 comments on commit f96dc18

Please sign in to comment.