Skip to content

Commit

Permalink
Support the allowed_instance_types option for terraform (LeanerCloud#192
Browse files Browse the repository at this point in the history
)
  • Loading branch information
binarylogic authored and cristim committed Feb 10, 2018
1 parent 659f81d commit 20fced1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions terraform/autospotting.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module "autospotting" {
source = "./autospotting"

autospotting_allowed_instance_types = "${var.asg_allowed_instance_types}"
autospotting_disallowed_instance_types = "${var.asg_disallowed_instance_types}"
autospotting_min_on_demand_number = "${var.asg_min_on_demand_number}"
autospotting_min_on_demand_percentage = "${var.asg_min_on_demand_percentage}"
Expand Down
1 change: 1 addition & 0 deletions terraform/autospotting/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ resource "aws_lambda_function" "autospotting" {

environment {
variables = {
ALLOWED_INSTANCE_TYPES = "${var.autospotting_allowed_instance_types}"
DISALLOWED_INSTANCE_TYPES = "${var.autospotting_disallowed_instance_types}"
MIN_ON_DEMAND_NUMBER = "${var.autospotting_min_on_demand_number}"
MIN_ON_DEMAND_PERCENTAGE = "${var.autospotting_min_on_demand_percentage}"
Expand Down
13 changes: 13 additions & 0 deletions terraform/autospotting/variables.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# Autospotting configuration
variable "autospotting_allowed_instance_types" {
description = <<EOF
Comma separated list of allowed instance types for spot requests,
in case you want to exclude specific types (also support globs).
Example: 't2.*,m4.large'
Using the 'current' magic value will only allow the same type as the
on-demand instances set in the group's launch configuration.
EOF
default = ""
}

variable "autospotting_disallowed_instance_types" {
description = <<EOF
Comma separated list of disallowed instance types for spot requests,
Expand Down
10 changes: 10 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# Autospotting configuration
variable "asg_allowed_instance_types" {
description = <<EOF
If specified, the spot instances will have a specific instance type:
current: the same as initial on-demand instances
<instance-type>: the actual instance type to use
EOF
default = ""
}

variable "asg_disallowed_instance_types" {
description = <<EOF
Comma separated list of disallowed instance types for spot requests,
Expand Down

0 comments on commit 20fced1

Please sign in to comment.