From 15bf1955bb8e2f31f1a9aebe4dcca701d231d5dd Mon Sep 17 00:00:00 2001 From: Amany El-Guindy Date: Wed, 1 Apr 2020 16:15:38 +0200 Subject: [PATCH] Add dyncmaic load_balancer_info block (#18) --- README.md | 1 + deployment-group-blue-green/main.tf | 8 ++++++++ deployment-group-blue-green/variables.tf | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/README.md b/README.md index b57f192..210e3e8 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ Creates a deployment group for a CodeDeploy app. This works in a blue/green way | terminate\_blue\_instances\_on\_deployment\_success | The action to take on instances in the original environment after a successful blue/green deployment | string | `"KEEP_ALIVE"` | no | | trigger\_events | events that can trigger the notifications | list | `` | no | | trigger\_target\_arn | ARN of the target group | string | n/a | yes | +| alb\_target\_group | Name of the ALB target group, to be used with blue/green deployment group | null | no ### Outputs diff --git a/deployment-group-blue-green/main.tf b/deployment-group-blue-green/main.tf index 56ae9ba..26832bc 100644 --- a/deployment-group-blue-green/main.tf +++ b/deployment-group-blue-green/main.tf @@ -9,6 +9,14 @@ resource "aws_codedeploy_deployment_group" "deployment_group" { enabled = var.rollback_enabled events = var.rollback_events } + dynamic "load_balancer_info" { + for_each = var.alb_target_group == null ? [] : [var.alb_target_group] + content { + target_group_info { + name = var.alb_target_group + } + } + } blue_green_deployment_config { deployment_ready_option { diff --git a/deployment-group-blue-green/variables.tf b/deployment-group-blue-green/variables.tf index cfb2810..ab10579 100644 --- a/deployment-group-blue-green/variables.tf +++ b/deployment-group-blue-green/variables.tf @@ -46,3 +46,9 @@ variable "terminate_blue_instances_on_deployment_success" { default = "KEEP_ALIVE" } +variable "alb_target_group" { + description = "Name of the ALB target group, to be used with blue/green deployment group" + default = null + type = string +} +