Skip to content

Commit f970467

Browse files
authored
Allow specifying spot_price (#23)
1 parent 6eb1464 commit f970467

File tree

5 files changed

+71
-29
lines changed

5 files changed

+71
-29
lines changed

README.md

+46-15
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,50 @@
11
# terraform-bluegreen
22
Terraform module to setup blue / green deployments
33

4-
##blue-green
4+
## blue-green
55

6-
### Variables
6+
### Inputs
77

8-
See the [blue-green/variables.tf](blue-green/variables.tf) file.
8+
| Name | Description | Type | Default | Required |
9+
|------|-------------|:----:|:-----:|:-----:|
10+
| associate\_public\_ip\_address | (Optional) Associate a public ip address with an instance in a VPC | string | `"false"` | no |
11+
| blue\_ami | (Required) The EC2 image ID to launch in the blue autoscaling group | string | n/a | yes |
12+
| blue\_desired\_capacity | (Required) The number of Amazon EC2 instances that should be running in the blue autoscaling roup | string | n/a | yes |
13+
| blue\_max\_size | (Required) The maximum size of the blue autoscaling group | string | n/a | yes |
14+
| blue\_min\_size | (Required) The minimum size of the blue autoscaling group | string | n/a | yes |
15+
| disk\_volume\_size | (Optional) The size of the volume in gigabytes | string | `"8"` | no |
16+
| disk\_volume\_type | (Optional) The type of the volume. Default is standard | string | `"standard"` | no |
17+
| environment | Environment to deploy on | string | n/a | yes |
18+
| green\_ami | (Required) The EC2 image ID to launch in the green autoscaling group | string | n/a | yes |
19+
| green\_desired\_capacity | (Required) The number of Amazon EC2 instances that should be running in the green autoscaling roup | string | n/a | yes |
20+
| green\_max\_size | (Required) The maximum size of the green autoscaling group | string | n/a | yes |
21+
| green\_min\_size | (Required) The minimum size of the green autoscaling group | string | n/a | yes |
22+
| health\_check\_grace\_period | (Optional, Default: 300) Time (in seconds) after instance comes into service before checking health | string | `"300"` | no |
23+
| health\_check\_type | The health check type to apply to the Autoscaling groups. | string | `"ELB"` | no |
24+
| iam\_instance\_profile | (Optional) The IAM instance profile to associate with launched instances | string | `""` | no |
25+
| instance\_type | (Required) The size of instance to launch | string | n/a | yes |
26+
| key\_name | (Optional) The key name that should be used for the instance | string | `""` | no |
27+
| loadbalancers | (Optional) A list of load balancer names to add to the autoscaling groups | list | `<list>` | no |
28+
| name | Name of the stack | string | n/a | yes |
29+
| project | Project name to use | string | n/a | yes |
30+
| security\_groups | (Optional) A list of associated security group IDS | list | `<list>` | no |
31+
| 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 |
32+
| subnets | (Optional) A list of subnet IDs to launch resources in | list | `<list>` | no |
33+
| tags | (Optional, Default: []) List of map of additional tags | list | `<list>` | no |
34+
| target\_group\_arns | A list of aws_alb_target_group ARNs, for use with Application Load Balancing | list | `<list>` | no |
35+
| termination\_policies | (Optional, Default: ['Default']) Order in termination policies to apply when choosing instances to terminate. | list | `<list>` | no |
36+
| user\_data | (Optional) The user data to provide when launching the instance | string | `"# Hello World"` | no |
937

1038
### Outputs
1139

12-
* `blue_asg_id`: (Number) blue autoscaling group id
13-
* `green_asg_id`: (Number) green autoscaling group id
40+
| Name | Description |
41+
|------|-------------|
42+
| blue\_asg\_id | |
43+
| green\_asg\_id | |
1444

1545
### Example
1646

17-
```
47+
```terraform
1848
module "bluegreen" {
1949
source = "github.com/skyscrapers/terraform-bluegreen//blue-green"
2050
project = "example"
@@ -35,9 +65,10 @@ module "bluegreen" {
3565
```
3666

3767
## scaling
68+
3869
Terraform module to setup alarms and autoscaling triggers for autoscaling
3970

40-
### Variables
71+
### Inputs
4172

4273
| Name | Description | Type | Default | Required |
4374
|------|-------------|:----:|:-----:|:-----:|
@@ -63,12 +94,9 @@ Terraform module to setup alarms and autoscaling triggers for autoscaling
6394
| threshold\_down | The metric value to scale down | string | `"30"` | no |
6495
| threshold\_up | The metric value to scale up | string | `"80"` | no |
6596

66-
### Outputs
67-
/
68-
6997
### Example
7098

71-
```
99+
```terraform
72100
module "scaling" {
73101
source = "github.com/skyscrapers/terraform-bluegreen//scaling"
74102
project = "example"
@@ -83,8 +111,9 @@ module "scaling" {
83111
The `bluegreen.py` script performs a bluegreen deployment of the selected terraform stack. It only works with Python 2.7.
84112
The blue-green deployment script expects certain inputs and outputs in the Terraform project you want to deploy in a blue-green fashion.
85113

86-
### Required outputs:
87-
```
114+
### Required outputs
115+
116+
```terraform
88117
output "blue_asg_id" {
89118
value = "${module.<blue-green-module-name>.blue_asg_id}"
90119
}
@@ -93,8 +122,10 @@ output "green_asg_id" {
93122
value = "${module.<blue-green-module-name>.green_asg_id}"
94123
}
95124
```
96-
### Required variables:
97-
```
125+
126+
### Required variables
127+
128+
```terraform
98129
variable "blue_max_size" {
99130
description = "max instances blue"
100131
}

blue-green/main.tf

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module "blue" {
2-
source = "../single-stack"
3-
color = "blue"
4-
max_size = "${var.blue_max_size}"
5-
min_size = "${var.blue_min_size}"
6-
desired_capacity = "${var.blue_desired_capacity}"
7-
ami = "${var.blue_ami}"
8-
2+
source = "../single-stack"
3+
color = "blue"
4+
max_size = "${var.blue_max_size}"
5+
min_size = "${var.blue_min_size}"
6+
desired_capacity = "${var.blue_desired_capacity}"
7+
ami = "${var.blue_ami}"
8+
spot_price = "${var.spot_price}"
99
loadbalancers = "${var.loadbalancers}"
1010
project = "${var.project}"
1111
name = "${var.name}"
@@ -27,13 +27,13 @@ module "blue" {
2727
}
2828

2929
module "green" {
30-
source = "../single-stack"
31-
color = "green"
32-
max_size = "${var.green_max_size}"
33-
min_size = "${var.green_min_size}"
34-
desired_capacity = "${var.green_desired_capacity}"
35-
ami = "${var.green_ami}"
36-
30+
source = "../single-stack"
31+
color = "green"
32+
max_size = "${var.green_max_size}"
33+
min_size = "${var.green_min_size}"
34+
desired_capacity = "${var.green_desired_capacity}"
35+
ami = "${var.green_ami}"
36+
spot_price = "${var.spot_price}"
3737
loadbalancers = "${var.loadbalancers}"
3838
project = "${var.project}"
3939
name = "${var.name}"

blue-green/variables.tf

+5
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,8 @@ variable "tags" {
121121
type = "list"
122122
default = []
123123
}
124+
125+
variable "spot_price" {
126+
description = "Spot price you want to pay for your instances. By default this is empty and we will use on-demand instances"
127+
default = ""
128+
}

single-stack/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ resource "aws_launch_configuration" "bluegreen_launchconfig" {
66
iam_instance_profile = "${var.iam_instance_profile}"
77
associate_public_ip_address = "${var.associate_public_ip_address}"
88
user_data = "${var.user_data}"
9+
spot_price = "${var.spot_price}"
910

1011
root_block_device {
1112
volume_type = "${var.disk_volume_type}"

single-stack/variables.tf

+5
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,8 @@ variable "tags" {
109109
type = "list"
110110
default = []
111111
}
112+
113+
variable "spot_price" {
114+
description = "Spot price you want to pay for your instances. By default this is empty and we will use on-demand instances"
115+
default = ""
116+
}

0 commit comments

Comments
 (0)