diff --git a/examples/ingress/outputs.tf b/examples/ingress/outputs.tf index 9c7a45e..8b251d8 100644 --- a/examples/ingress/outputs.tf +++ b/examples/ingress/outputs.tf @@ -10,6 +10,9 @@ output "security_group" { output "load_balancer" { value = module.this.load_balancer } +output "load_balancer_target_groups" { + value = module.this.load_balancer_target_groups +} output "domain" { value = module.this.domain } diff --git a/flake.lock b/flake.lock index cc2e8ff..69813e5 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1713254108, - "narHash": "sha256-0TZIsfDbHG5zibtlw6x0yOp3jkInIGaJ35B7Y4G8Pec=", + "lastModified": 1713284584, + "narHash": "sha256-rRuPBJD9+yjz7tY3xC/BvFUwloutynR9piiVE6fhGqo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2fd19c8be2551a61c1ddc3d9f86d748f4db94f00", + "rev": "2b6ee326ad047870526d9a3ae88dfd0197da898d", "type": "github" }, "original": { diff --git a/modules/network_load_balancer/outputs.tf b/modules/network_load_balancer/outputs.tf index 0fa3feb..ecc90ff 100644 --- a/modules/network_load_balancer/outputs.tf +++ b/modules/network_load_balancer/outputs.tf @@ -12,4 +12,7 @@ output "public_ip" { } output "listeners" { value = (local.create == 1 ? aws_lb_listener.created : {}) +} +output "target_groups" { + value = aws_lb_target_group.created } \ No newline at end of file diff --git a/outputs.tf b/outputs.tf index f5e5c10..ff35cc8 100644 --- a/outputs.tf +++ b/outputs.tf @@ -98,6 +98,34 @@ output "load_balancer" { EOT } +output "load_balancer_target_groups" { + value = (length(module.network_load_balancer) > 0 ? [ + for k, v in module.network_load_balancer[0].target_groups : + { + id = v.id + arn = v.arn + name_prefix = v.name_prefix + port = v.port + protocol = v.protocol + tags_all = v.tags_all + } + ] : [{ + id = "" + arn = "" + name_prefix = "" + port = "" + protocol = "" + tags_all = tomap({ "" = "" }) + } + ] + ) + description = <<-EOT + The load balancer target groups from AWS. + When generated, this can be helpful to set up indirect access to servers. + To attach servers, use the target_group_attachment resource. + EOT +} + output "domain" { value = (length(module.domain) > 0 ? { id = module.domain[0].domain.id