Skip to content

Commit f97842f

Browse files
authored
Upgrade to Terraform 0.12 (#27)
* 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
1 parent ae09461 commit f97842f

13 files changed

+285
-187
lines changed

README.md

+30-30
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,36 @@ Terraform module to setup blue / green deployments
88

99
| Name | Description | Type | Default | Required |
1010
|------|-------------|:----:|:-----:|:-----:|
11-
| associate\_public\_ip\_address | Associate a public ip address with an instance in a VPC | string | `"false"` | no |
11+
| associate\_public\_ip\_address | Associate a public ip address with an instance in a VPC | bool | `false` | no |
1212
| blue\_ami | The EC2 image ID to launch in the Blue autoscaling group | string | n/a | yes |
13-
| blue\_desired\_capacity | The number of Amazon EC2 instances that should be running in the blue autoscaling roup | string | n/a | yes |
14-
| blue\_disk\_volume\_size | The size of the EBS volume in GB for the Blue instances | string | `"8"` | no |
13+
| blue\_desired\_capacity | The number of Amazon EC2 instances that should be running in the blue autoscaling roup | number | n/a | yes |
14+
| blue\_disk\_volume\_size | The size of the EBS volume in GB for the Blue instances | number | `8` | no |
1515
| blue\_disk\_volume\_type | The EBS volume type for the Blue instances | string | `"gp2"` | no |
1616
| blue\_instance\_type | The Blue instance type to launch | string | n/a | yes |
17-
| blue\_max\_size | The maximum size of the blue autoscaling group | string | n/a | yes |
18-
| blue\_min\_size | The minimum size of the blue autoscaling group | string | n/a | yes |
17+
| blue\_max\_size | The maximum size of the blue autoscaling group | number | n/a | yes |
18+
| blue\_min\_size | The minimum size of the blue autoscaling group | number | n/a | yes |
1919
| blue\_user\_data | The user data to provide when launching the Blue instances | string | `"# Hello World"` | no |
2020
| green\_ami | The EC2 image ID to launch in the Green autoscaling group | string | n/a | yes |
21-
| green\_desired\_capacity | The number of Amazon EC2 instances that should be running in the green autoscaling roup | string | n/a | yes |
22-
| green\_disk\_volume\_size | The size of the EBS volume in GB for the Green instances | string | `"8"` | no |
21+
| green\_desired\_capacity | The number of Amazon EC2 instances that should be running in the green autoscaling roup | number | n/a | yes |
22+
| green\_disk\_volume\_size | The size of the EBS volume in GB for the Green instances | number | `8` | no |
2323
| green\_disk\_volume\_type | The EBS volume type for the Green instances | string | `"gp2"` | no |
2424
| green\_instance\_type | The Green instance type to launch | string | n/a | yes |
25-
| green\_max\_size | The maximum size of the green autoscaling group | string | n/a | yes |
26-
| green\_min\_size | The minimum size of the green autoscaling group | string | n/a | yes |
25+
| green\_max\_size | The maximum size of the green autoscaling group | number | n/a | yes |
26+
| green\_min\_size | The minimum size of the green autoscaling group | number | n/a | yes |
2727
| green\_user\_data | The user data to provide when launching the Green instances | string | `"# Hello World"` | no |
28-
| health\_check\_grace\_period | Time (in seconds) after instance comes into service before checking health | string | `"300"` | no |
28+
| health\_check\_grace\_period | Time (in seconds) after instance comes into service before checking health | number | `300` | no |
2929
| health\_check\_type | The health check type to apply to the Autoscaling groups. | string | `"ELB"` | no |
30-
| iam\_instance\_profile | The IAM instance profile to associate with launched instances | string | `""` | no |
31-
| 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 |
32-
| key\_name | The key name that should be used for the instance | string | `""` | no |
33-
| loadbalancers | A list of load balancer names to add to the autoscaling groups | list | `<list>` | no |
30+
| iam\_instance\_profile | The IAM instance profile to associate with launched instances | string | `null` | no |
31+
| 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 |
32+
| key\_name | The key name that should be used for the instance | string | `null` | no |
33+
| loadbalancers | A list of load balancer names to add to the autoscaling groups | list(string) | `[]` | no |
3434
| name | Name of the Auto Scaling Groups | string | n/a | yes |
35-
| security\_groups | A list of associated security group IDS | list | `<list>` | no |
35+
| security\_groups | A list of associated security group IDS | list(string) | `[]` | no |
3636
| 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 |
37-
| subnets | A list of subnet IDs to launch resources in | list | `<list>` | no |
38-
| tags | List as a map of additional tags | list | `<list>` | no |
39-
| target\_group\_arns | A list of aws_alb_target_group ARNs, for use with Application Load Balancing | list | `<list>` | no |
40-
| termination\_policies | Order in termination policies to apply when choosing instances to terminate. | list | `<list>` | no |
37+
| subnets | A list of subnet IDs to launch resources in | list(string) | `[]` | no |
38+
| tags | List as a map of additional tags | list(map(string)) | `[]` | no |
39+
| target\_group\_arns | A list of aws_alb_target_group ARNs, for use with Application Load Balancing | list(string) | `[]` | no |
40+
| termination\_policies | Order in termination policies to apply when choosing instances to terminate. | list(string) | `[]` | no |
4141
| 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 |
4242

4343
### Outputs
@@ -78,25 +78,25 @@ Terraform module to setup alarms and autoscaling triggers for autoscaling
7878

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

101101
### Example
102102

blue-green/main.tf

+46-46
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
module "blue" {
22
source = "../single-stack"
33
color = "blue"
4-
name = "${var.name}"
5-
max_size = "${var.blue_max_size}"
6-
min_size = "${var.blue_min_size}"
7-
desired_capacity = "${var.blue_desired_capacity}"
8-
ami = "${var.blue_ami}"
9-
user_data = "${var.blue_user_data}"
10-
instance_type = "${var.blue_instance_type}"
11-
disk_volume_size = "${var.blue_disk_volume_size}"
12-
disk_volume_type = "${var.blue_disk_volume_type}"
13-
spot_price = "${var.spot_price}"
14-
loadbalancers = ["${var.loadbalancers}"]
15-
key_name = "${var.key_name}"
16-
security_groups = ["${var.security_groups}"]
17-
iam_instance_profile = "${var.iam_instance_profile}"
18-
associate_public_ip_address = "${var.associate_public_ip_address}"
19-
subnets = "${var.subnets}"
20-
health_check_grace_period = "${var.health_check_grace_period}"
21-
termination_policies = ["${var.termination_policies}"]
22-
target_group_arns = ["${var.target_group_arns}"]
23-
health_check_type = "${var.health_check_type}"
24-
wait_for_capacity_timeout = "${var.wait_for_capacity_timeout}"
25-
tags = "${var.tags}"
26-
initial_lifecycle_hooks = ["${var.initial_lifecycle_hooks}"]
4+
name = var.name
5+
max_size = var.blue_max_size
6+
min_size = var.blue_min_size
7+
desired_capacity = var.blue_desired_capacity
8+
ami = var.blue_ami
9+
user_data = var.blue_user_data
10+
instance_type = var.blue_instance_type
11+
disk_volume_size = var.blue_disk_volume_size
12+
disk_volume_type = var.blue_disk_volume_type
13+
spot_price = var.spot_price
14+
loadbalancers = var.loadbalancers
15+
key_name = var.key_name
16+
security_groups = var.security_groups
17+
iam_instance_profile = var.iam_instance_profile
18+
associate_public_ip_address = var.associate_public_ip_address
19+
subnets = var.subnets
20+
health_check_grace_period = var.health_check_grace_period
21+
termination_policies = var.termination_policies
22+
target_group_arns = var.target_group_arns
23+
health_check_type = var.health_check_type
24+
wait_for_capacity_timeout = var.wait_for_capacity_timeout
25+
tags = var.tags
26+
initial_lifecycle_hooks = var.initial_lifecycle_hooks
2727
}
2828

2929
module "green" {
3030
source = "../single-stack"
3131
color = "green"
32-
name = "${var.name}"
33-
max_size = "${var.green_max_size}"
34-
min_size = "${var.green_min_size}"
35-
desired_capacity = "${var.green_desired_capacity}"
36-
ami = "${var.green_ami}"
37-
user_data = "${var.green_user_data}"
38-
instance_type = "${var.green_instance_type}"
39-
disk_volume_size = "${var.green_disk_volume_size}"
40-
disk_volume_type = "${var.green_disk_volume_type}"
41-
spot_price = "${var.spot_price}"
42-
loadbalancers = ["${var.loadbalancers}"]
43-
key_name = "${var.key_name}"
44-
security_groups = ["${var.security_groups}"]
45-
iam_instance_profile = "${var.iam_instance_profile}"
46-
associate_public_ip_address = "${var.associate_public_ip_address}"
47-
subnets = "${var.subnets}"
48-
health_check_grace_period = "${var.health_check_grace_period}"
49-
termination_policies = ["${var.termination_policies}"]
50-
target_group_arns = ["${var.target_group_arns}"]
51-
health_check_type = "${var.health_check_type}"
52-
wait_for_capacity_timeout = "${var.wait_for_capacity_timeout}"
53-
tags = "${var.tags}"
54-
initial_lifecycle_hooks = ["${var.initial_lifecycle_hooks}"]
32+
name = var.name
33+
max_size = var.green_max_size
34+
min_size = var.green_min_size
35+
desired_capacity = var.green_desired_capacity
36+
ami = var.green_ami
37+
user_data = var.green_user_data
38+
instance_type = var.green_instance_type
39+
disk_volume_size = var.green_disk_volume_size
40+
disk_volume_type = var.green_disk_volume_type
41+
spot_price = var.spot_price
42+
loadbalancers = var.loadbalancers
43+
key_name = var.key_name
44+
security_groups = var.security_groups
45+
iam_instance_profile = var.iam_instance_profile
46+
associate_public_ip_address = var.associate_public_ip_address
47+
subnets = var.subnets
48+
health_check_grace_period = var.health_check_grace_period
49+
termination_policies = var.termination_policies
50+
target_group_arns = var.target_group_arns
51+
health_check_type = var.health_check_type
52+
wait_for_capacity_timeout = var.wait_for_capacity_timeout
53+
tags = var.tags
54+
initial_lifecycle_hooks = var.initial_lifecycle_hooks
5555
}

blue-green/outputs.tf

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
output "blue_asg_id" {
22
description = "Blue autoscaling group id"
3-
value = "${module.blue.asg_id}"
3+
value = module.blue.asg_id
44
}
55

66
output "green_asg_id" {
77
description = "Green autoscaling group id"
8-
value = "${module.green.asg_id}"
8+
value = module.green.asg_id
99
}
1010

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

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

0 commit comments

Comments
 (0)