Skip to content

Commit

Permalink
Better ALB Target Group naming (#8)
Browse files Browse the repository at this point in the history
* fix issue with passed parameter value
  • Loading branch information
sarkis authored Jul 15, 2018
1 parent a08f67c commit d12e9ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ It's 100% Open Source and licensed under the [APACHE2](LICENSE).







## Usage

Include this module in your existing terraform code:
Expand Down Expand Up @@ -178,6 +182,13 @@ See [LICENSE](LICENSE) for full details.
under the License.









## Trademarks

All other trademarks referenced herein are the property of their respective owners.
Expand Down
8 changes: 4 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
locals {
generate_target_group_arn = "${var.target_group_arn == "" ? 1 : 0}"
create_target_group = "${var.target_group_arn == "" ? "true" : "false"}"
}

locals {
target_group_arn = "${local.generate_target_group_arn ? aws_lb_target_group.default.arn : var.target_group_arn}"
target_group_arn = "${local.create_target_group == "true" ? aws_lb_target_group.default.arn : var.target_group_arn}"
}

data "aws_lb_target_group" "default" {
arn = "${local.target_group_arn}"
}

module "default_label" {
enabled = "${local.create_target_group}"
source = "git::https://github.com/cloudposse/terraform-terraform-label.git?ref=tags/0.1.3"
enabled = "${local.generate_target_group_arn}"
attributes = "${var.attributes}"
delimiter = "${var.delimiter}"
name = "${var.name}"
Expand All @@ -22,7 +22,7 @@ module "default_label" {
}

resource "aws_lb_target_group" "default" {
count = "${local.generate_target_group_arn}"
count = "${local.create_target_group == "true" ? 1 : 0}"
name = "${module.default_label.id}"
port = "${var.port}"
protocol = "${var.protocol}"
Expand Down

0 comments on commit d12e9ea

Please sign in to comment.