Skip to content

Commit

Permalink
Upgrade to Terraform 0.12 (#27)
Browse files Browse the repository at this point in the history
* Upgrade tf code to 0.12

* Fix tf interpolation

* Fix type

* Use null for spot_price by default

* Set some more nulls as defaults

* Bump default tf version in the ci task
  • Loading branch information
iuriaranda authored Jun 4, 2019
1 parent ae09461 commit f97842f
Show file tree
Hide file tree
Showing 13 changed files with 285 additions and 187 deletions.
60 changes: 30 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,36 @@ Terraform module to setup blue / green deployments

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| associate\_public\_ip\_address | Associate a public ip address with an instance in a VPC | string | `"false"` | no |
| associate\_public\_ip\_address | Associate a public ip address with an instance in a VPC | bool | `false` | no |
| blue\_ami | The EC2 image ID to launch in the Blue autoscaling group | string | n/a | yes |
| blue\_desired\_capacity | The number of Amazon EC2 instances that should be running in the blue autoscaling roup | string | n/a | yes |
| blue\_disk\_volume\_size | The size of the EBS volume in GB for the Blue instances | string | `"8"` | no |
| blue\_desired\_capacity | The number of Amazon EC2 instances that should be running in the blue autoscaling roup | number | n/a | yes |
| blue\_disk\_volume\_size | The size of the EBS volume in GB for the Blue instances | number | `8` | no |
| blue\_disk\_volume\_type | The EBS volume type for the Blue instances | string | `"gp2"` | no |
| blue\_instance\_type | The Blue instance type to launch | string | n/a | yes |
| blue\_max\_size | The maximum size of the blue autoscaling group | string | n/a | yes |
| blue\_min\_size | The minimum size of the blue autoscaling group | string | n/a | yes |
| blue\_max\_size | The maximum size of the blue autoscaling group | number | n/a | yes |
| blue\_min\_size | The minimum size of the blue autoscaling group | number | n/a | yes |
| blue\_user\_data | The user data to provide when launching the Blue instances | string | `"# Hello World"` | no |
| green\_ami | The EC2 image ID to launch in the Green autoscaling group | string | n/a | yes |
| green\_desired\_capacity | The number of Amazon EC2 instances that should be running in the green autoscaling roup | string | n/a | yes |
| green\_disk\_volume\_size | The size of the EBS volume in GB for the Green instances | string | `"8"` | no |
| green\_desired\_capacity | The number of Amazon EC2 instances that should be running in the green autoscaling roup | number | n/a | yes |
| green\_disk\_volume\_size | The size of the EBS volume in GB for the Green instances | number | `8` | no |
| green\_disk\_volume\_type | The EBS volume type for the Green instances | string | `"gp2"` | no |
| green\_instance\_type | The Green instance type to launch | string | n/a | yes |
| green\_max\_size | The maximum size of the green autoscaling group | string | n/a | yes |
| green\_min\_size | The minimum size of the green autoscaling group | string | n/a | yes |
| green\_max\_size | The maximum size of the green autoscaling group | number | n/a | yes |
| green\_min\_size | The minimum size of the green autoscaling group | number | n/a | yes |
| green\_user\_data | The user data to provide when launching the Green instances | string | `"# Hello World"` | no |
| health\_check\_grace\_period | Time (in seconds) after instance comes into service before checking health | string | `"300"` | no |
| health\_check\_grace\_period | Time (in seconds) after instance comes into service before checking health | number | `300` | no |
| health\_check\_type | The health check type to apply to the Autoscaling groups. | string | `"ELB"` | no |
| iam\_instance\_profile | The IAM instance profile to associate with launched instances | string | `""` | no |
| initial\_lifecycle\_hooks | One or more [Lifecycle Hooks](http://docs.aws.amazon.com/autoscaling/latest/userguide/lifecycle-hooks.html) to attach to the autoscaling group before instances are launched. The syntax is exactly the same as the separate [`aws_autoscaling_lifecycle_hook`](https://www.terraform.io/docs/providers/aws/r/autoscaling_lifecycle_hooks.html) resource, without the autoscaling_group_name attribute | list | `<list>` | no |
| key\_name | The key name that should be used for the instance | string | `""` | no |
| loadbalancers | A list of load balancer names to add to the autoscaling groups | list | `<list>` | no |
| iam\_instance\_profile | The IAM instance profile to associate with launched instances | string | `null` | no |
| initial\_lifecycle\_hooks | One or more [Lifecycle Hooks](http://docs.aws.amazon.com/autoscaling/latest/userguide/lifecycle-hooks.html) to attach to the autoscaling group before instances are launched. The syntax is exactly the same as the separate [`aws_autoscaling_lifecycle_hook`](https://www.terraform.io/docs/providers/aws/r/autoscaling_lifecycle_hooks.html) resource, without the autoscaling_group_name attribute | list(map(string)) | `[]` | no |
| key\_name | The key name that should be used for the instance | string | `null` | no |
| loadbalancers | A list of load balancer names to add to the autoscaling groups | list(string) | `[]` | no |
| name | Name of the Auto Scaling Groups | string | n/a | yes |
| security\_groups | A list of associated security group IDS | list | `<list>` | no |
| security\_groups | A list of associated security group IDS | list(string) | `[]` | no |
| spot\_price | Spot price you want to pay for your instances. By default this is empty and we will use on-demand instances | string | `""` | no |
| subnets | A list of subnet IDs to launch resources in | list | `<list>` | no |
| tags | List as a map of additional tags | list | `<list>` | no |
| target\_group\_arns | A list of aws_alb_target_group ARNs, for use with Application Load Balancing | list | `<list>` | no |
| termination\_policies | Order in termination policies to apply when choosing instances to terminate. | list | `<list>` | no |
| subnets | A list of subnet IDs to launch resources in | list(string) | `[]` | no |
| tags | List as a map of additional tags | list(map(string)) | `[]` | no |
| target\_group\_arns | A list of aws_alb_target_group ARNs, for use with Application Load Balancing | list(string) | `[]` | no |
| termination\_policies | Order in termination policies to apply when choosing instances to terminate. | list(string) | `[]` | 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
Expand Down Expand Up @@ -78,25 +78,25 @@ Terraform module to setup alarms and autoscaling triggers for autoscaling

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| adjustment\_down | The number of instances to remove when the alarm is triggered (the value has to be negative) | string | `"-1"` | no |
| adjustment\_down | The number of instances to remove when the alarm is triggered (the value has to be negative) | number | `-1` | no |
| adjustment\_type | What typ of adjustment needs to happen | string | `"ChangeInCapacity"` | no |
| adjustment\_up | The number of instances to add when the alarm is triggered | string | `"1"` | no |
| adjustment\_up | The number of instances to add when the alarm is triggered | number | `1` | no |
| autoscaling\_group\_names | The names of the Auto Scaling Groups this config needs to be applied to | list | n/a | yes |
| cooldown\_down | The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start. | string | `"600"` | no |
| cooldown\_up | The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start. | string | `"300"` | no |
| cooldown\_down | The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start. | number | `600` | no |
| cooldown\_up | The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start. | number | `300` | no |
| dimension\_name | | string | `"AutoScalingGroupName"` | no |
| dimension\_value | | string | `"false"` | no |
| evaluation\_periods | The number of samples to evaluate | string | `"4"` | no |
| dimension\_value | | bool | `false` | no |
| evaluation\_periods | The number of samples to evaluate | number | `4` | no |
| metric\_name | The metric the scaling is based upon | string | `"CPUUtilization"` | no |
| name | Name of the Auto Scaling Groups | string | n/a | yes |
| namespace | The namespace of the cloudwatch metric | string | `"AWS/EC2"` | no |
| num\_asg | The number of autoscaling groups passed | string | `"2"` | no |
| period\_down | The period in seconds over which the selected metric statistic is applied. | string | `"120"` | no |
| period\_up | The period in seconds over which the selected metric statistic is applied. | string | `"60"` | no |
| num\_asg | The number of autoscaling groups passed | number | `2` | no |
| period\_down | The period in seconds over which the selected metric statistic is applied. | number | `120` | no |
| period\_up | The period in seconds over which the selected metric statistic is applied. | number | `60` | no |
| policy\_type | The policy type, either SimpleScaling or StepScaling | string | `"SimpleScaling"` | no |
| statistic | The statistic to apply to the alarm's associated metric. Either of the following is supported: | string | `"Average"` | no |
| threshold\_down | The metric value to scale down | string | `"30"` | no |
| threshold\_up | The metric value to scale up | string | `"80"` | no |
| threshold\_down | The metric value to scale down | number | `30` | no |
| threshold\_up | The metric value to scale up | number | `80` | no |

### Example

Expand Down
92 changes: 46 additions & 46 deletions blue-green/main.tf
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
module "blue" {
source = "../single-stack"
color = "blue"
name = "${var.name}"
max_size = "${var.blue_max_size}"
min_size = "${var.blue_min_size}"
desired_capacity = "${var.blue_desired_capacity}"
ami = "${var.blue_ami}"
user_data = "${var.blue_user_data}"
instance_type = "${var.blue_instance_type}"
disk_volume_size = "${var.blue_disk_volume_size}"
disk_volume_type = "${var.blue_disk_volume_type}"
spot_price = "${var.spot_price}"
loadbalancers = ["${var.loadbalancers}"]
key_name = "${var.key_name}"
security_groups = ["${var.security_groups}"]
iam_instance_profile = "${var.iam_instance_profile}"
associate_public_ip_address = "${var.associate_public_ip_address}"
subnets = "${var.subnets}"
health_check_grace_period = "${var.health_check_grace_period}"
termination_policies = ["${var.termination_policies}"]
target_group_arns = ["${var.target_group_arns}"]
health_check_type = "${var.health_check_type}"
wait_for_capacity_timeout = "${var.wait_for_capacity_timeout}"
tags = "${var.tags}"
initial_lifecycle_hooks = ["${var.initial_lifecycle_hooks}"]
name = var.name
max_size = var.blue_max_size
min_size = var.blue_min_size
desired_capacity = var.blue_desired_capacity
ami = var.blue_ami
user_data = var.blue_user_data
instance_type = var.blue_instance_type
disk_volume_size = var.blue_disk_volume_size
disk_volume_type = var.blue_disk_volume_type
spot_price = var.spot_price
loadbalancers = var.loadbalancers
key_name = var.key_name
security_groups = var.security_groups
iam_instance_profile = var.iam_instance_profile
associate_public_ip_address = var.associate_public_ip_address
subnets = var.subnets
health_check_grace_period = var.health_check_grace_period
termination_policies = var.termination_policies
target_group_arns = var.target_group_arns
health_check_type = var.health_check_type
wait_for_capacity_timeout = var.wait_for_capacity_timeout
tags = var.tags
initial_lifecycle_hooks = var.initial_lifecycle_hooks
}

module "green" {
source = "../single-stack"
color = "green"
name = "${var.name}"
max_size = "${var.green_max_size}"
min_size = "${var.green_min_size}"
desired_capacity = "${var.green_desired_capacity}"
ami = "${var.green_ami}"
user_data = "${var.green_user_data}"
instance_type = "${var.green_instance_type}"
disk_volume_size = "${var.green_disk_volume_size}"
disk_volume_type = "${var.green_disk_volume_type}"
spot_price = "${var.spot_price}"
loadbalancers = ["${var.loadbalancers}"]
key_name = "${var.key_name}"
security_groups = ["${var.security_groups}"]
iam_instance_profile = "${var.iam_instance_profile}"
associate_public_ip_address = "${var.associate_public_ip_address}"
subnets = "${var.subnets}"
health_check_grace_period = "${var.health_check_grace_period}"
termination_policies = ["${var.termination_policies}"]
target_group_arns = ["${var.target_group_arns}"]
health_check_type = "${var.health_check_type}"
wait_for_capacity_timeout = "${var.wait_for_capacity_timeout}"
tags = "${var.tags}"
initial_lifecycle_hooks = ["${var.initial_lifecycle_hooks}"]
name = var.name
max_size = var.green_max_size
min_size = var.green_min_size
desired_capacity = var.green_desired_capacity
ami = var.green_ami
user_data = var.green_user_data
instance_type = var.green_instance_type
disk_volume_size = var.green_disk_volume_size
disk_volume_type = var.green_disk_volume_type
spot_price = var.spot_price
loadbalancers = var.loadbalancers
key_name = var.key_name
security_groups = var.security_groups
iam_instance_profile = var.iam_instance_profile
associate_public_ip_address = var.associate_public_ip_address
subnets = var.subnets
health_check_grace_period = var.health_check_grace_period
termination_policies = var.termination_policies
target_group_arns = var.target_group_arns
health_check_type = var.health_check_type
wait_for_capacity_timeout = var.wait_for_capacity_timeout
tags = var.tags
initial_lifecycle_hooks = var.initial_lifecycle_hooks
}
8 changes: 4 additions & 4 deletions blue-green/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
output "blue_asg_id" {
description = "Blue autoscaling group id"
value = "${module.blue.asg_id}"
value = module.blue.asg_id
}

output "green_asg_id" {
description = "Green autoscaling group id"
value = "${module.green.asg_id}"
value = module.green.asg_id
}

output "nonbinding_blue_asg_name" {
description = "This is the raw blue autoscaling group name, without creating a dependency with the actual autoscaling group resource"
value = "${module.blue.nonbinding_asg_name}"
value = module.blue.nonbinding_asg_name
}

output "nonbinding_green_asg_name" {
description = "This is the raw green autoscaling group name, without creating a dependency with the actual autoscaling group resource"
value = "${module.green.nonbinding_asg_name}"
value = module.green.nonbinding_asg_name
}
Loading

0 comments on commit f97842f

Please sign in to comment.