From 6f623385b0c9aa8504daa6cff5d8e1b217ddb1a3 Mon Sep 17 00:00:00 2001 From: Luca Venturelli Date: Tue, 9 Apr 2019 10:04:59 -0500 Subject: [PATCH] adding option to specify wait_for_capacity_timeout (#24) --- README.md | 5 +++-- blue-green/main.tf | 2 ++ blue-green/outputs.tf | 2 ++ blue-green/variables.tf | 5 +++++ single-stack/main.tf | 3 ++- single-stack/variables.tf | 5 +++++ 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c9b566d..b97f4c6 100644 --- a/README.md +++ b/README.md @@ -34,13 +34,14 @@ Terraform module to setup blue / green deployments | target\_group\_arns | A list of aws_alb_target_group ARNs, for use with Application Load Balancing | list | `` | no | | termination\_policies | (Optional, Default: ['Default']) Order in termination policies to apply when choosing instances to terminate. | list | `` | no | | user\_data | (Optional) The user data to provide when launching the instance | string | `"# Hello World"` | no | +| wait\_for\_capacity\_timeout | A maximum duration that Terraform should wait for ASG instances to be healthy before timing out. Setting this to 0 causes Terraform to skip all Capacity Waiting behavior. | string | `"10m"` | no | ### Outputs | Name | Description | |------|-------------| -| blue\_asg\_id | | -| green\_asg\_id | | +| blue\_asg\_id | Blue autoscaling group id | +| green\_asg\_id | Green autoscaling group id | ### Example diff --git a/blue-green/main.tf b/blue-green/main.tf index 216ef21..69a7f7a 100644 --- a/blue-green/main.tf +++ b/blue-green/main.tf @@ -24,6 +24,7 @@ module "blue" { target_group_arns = "${var.target_group_arns}" health_check_type = "${var.health_check_type}" tags = "${var.tags}" + wait_for_capacity_timeout = "${var.wait_for_capacity_timeout}" } module "green" { @@ -52,4 +53,5 @@ module "green" { target_group_arns = "${var.target_group_arns}" health_check_type = "${var.health_check_type}" tags = "${var.tags}" + wait_for_capacity_timeout = "${var.wait_for_capacity_timeout}" } diff --git a/blue-green/outputs.tf b/blue-green/outputs.tf index 9012087..c71ced9 100644 --- a/blue-green/outputs.tf +++ b/blue-green/outputs.tf @@ -1,7 +1,9 @@ output "blue_asg_id" { + description = "Blue autoscaling group id" value = "${module.blue.asg_id}" } output "green_asg_id" { + description = "Green autoscaling group id" value = "${module.green.asg_id}" } diff --git a/blue-green/variables.tf b/blue-green/variables.tf index fb185a7..fb2a9d1 100644 --- a/blue-green/variables.tf +++ b/blue-green/variables.tf @@ -126,3 +126,8 @@ variable "spot_price" { description = "Spot price you want to pay for your instances. By default this is empty and we will use on-demand instances" default = "" } + +variable "wait_for_capacity_timeout" { + description = " A maximum duration that Terraform should wait for ASG instances to be healthy before timing out. Setting this to 0 causes Terraform to skip all Capacity Waiting behavior." + default = "10m" +} diff --git a/single-stack/main.tf b/single-stack/main.tf index 44f00d6..1dafca7 100644 --- a/single-stack/main.tf +++ b/single-stack/main.tf @@ -31,7 +31,8 @@ resource "aws_autoscaling_group" "bluegreen_asg" { health_check_grace_period = "${var.health_check_grace_period}" termination_policies = ["${var.termination_policies}"] target_group_arns = ["${var.target_group_arns}"] - + wait_for_capacity_timeout = "${var.wait_for_capacity_timeout}" + tags = ["${concat( list( map("key", "Environment", "value", "${var.environment}", "propagate_at_launch", true), diff --git a/single-stack/variables.tf b/single-stack/variables.tf index e7690d0..7867cfc 100644 --- a/single-stack/variables.tf +++ b/single-stack/variables.tf @@ -114,3 +114,8 @@ variable "spot_price" { description = "Spot price you want to pay for your instances. By default this is empty and we will use on-demand instances" default = "" } + +variable "wait_for_capacity_timeout" { + description = "A maximum duration that Terraform should wait for ASG instances to be healthy before timing out. Setting this to 0 causes Terraform to skip all Capacity Waiting behavior." + default = "10m" +}