Skip to content

Commit

Permalink
Expose new configuration options
Browse files Browse the repository at this point in the history
  • Loading branch information
cristim committed Jun 19, 2021
1 parent 2a07c8f commit 1836c81
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 39 deletions.
40 changes: 21 additions & 19 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,27 @@ module "aws_lambda_function" {

sqs_fifo_queue_name = "${module.label.id}.fifo"

autospotting_allowed_instance_types = var.autospotting_allowed_instance_types
autospotting_bidding_policy = var.autospotting_bidding_policy
autospotting_cron_schedule = var.autospotting_cron_schedule
autospotting_cron_schedule_state = var.autospotting_cron_schedule_state
autospotting_cron_timezone = var.autospotting_cron_timezone
autospotting_disallowed_instance_types = var.autospotting_disallowed_instance_types
autospotting_instance_termination_method = var.autospotting_instance_termination_method
autospotting_license = var.autospotting_license
autospotting_min_on_demand_number = var.autospotting_min_on_demand_number
autospotting_min_on_demand_percentage = var.autospotting_min_on_demand_percentage
autospotting_on_demand_price_multiplier = var.autospotting_on_demand_price_multiplier
autospotting_patch_beanswalk_userdata = var.autospotting_patch_beanswalk_userdata
autospotting_regions_enabled = var.autospotting_regions_enabled
autospotting_spot_price_buffer_percentage = var.autospotting_spot_price_buffer_percentage
autospotting_spot_product_description = var.autospotting_spot_product_description
autospotting_spot_product_premium = var.autospotting_spot_product_premium
autospotting_tag_filtering_mode = var.autospotting_tag_filtering_mode
autospotting_tag_filters = var.autospotting_tag_filters
autospotting_termination_notification_action = var.autospotting_termination_notification_action
autospotting_allowed_instance_types = var.autospotting_allowed_instance_types
autospotting_bidding_policy = var.autospotting_bidding_policy
autospotting_cron_schedule = var.autospotting_cron_schedule
autospotting_cron_schedule_state = var.autospotting_cron_schedule_state
autospotting_cron_timezone = var.autospotting_cron_timezone
autospotting_disable_event_based_instance_replacement = var.autospotting_disable_event_based_instance_replacement
autospotting_disallowed_instance_types = var.autospotting_disallowed_instance_types
autospotting_ebs_gp2_conversion_threshold = var.autospotting_ebs_gp2_conversion_threshold
autospotting_instance_termination_method = var.autospotting_instance_termination_method
autospotting_license = var.autospotting_license
autospotting_min_on_demand_number = var.autospotting_min_on_demand_number
autospotting_min_on_demand_percentage = var.autospotting_min_on_demand_percentage
autospotting_on_demand_price_multiplier = var.autospotting_on_demand_price_multiplier
autospotting_patch_beanswalk_userdata = var.autospotting_patch_beanswalk_userdata
autospotting_regions_enabled = var.autospotting_regions_enabled
autospotting_spot_price_buffer_percentage = var.autospotting_spot_price_buffer_percentage
autospotting_spot_product_description = var.autospotting_spot_product_description
autospotting_spot_product_premium = var.autospotting_spot_product_premium
autospotting_tag_filtering_mode = var.autospotting_tag_filtering_mode
autospotting_tag_filters = var.autospotting_tag_filters
autospotting_termination_notification_action = var.autospotting_termination_notification_action
}

# Regional resources that trigger the main Lambda function
Expand Down
42 changes: 22 additions & 20 deletions modules/lambda/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,28 @@ resource "aws_lambda_function" "autospotting" {

environment {
variables = {
ALLOWED_INSTANCE_TYPES = var.autospotting_allowed_instance_types
BIDDING_POLICY = var.autospotting_bidding_policy
CRON_SCHEDULE = var.autospotting_cron_schedule
CRON_SCHEDULE_STATE = var.autospotting_cron_schedule_state
CRON_TIMEZONE = var.autospotting_cron_timezone
DISALLOWED_INSTANCE_TYPES = var.autospotting_disallowed_instance_types
INSTANCE_TERMINATION_METHOD = var.autospotting_instance_termination_method
LICENSE = var.autospotting_license
MIN_ON_DEMAND_NUMBER = var.autospotting_min_on_demand_number
MIN_ON_DEMAND_PERCENTAGE = var.autospotting_min_on_demand_percentage
ON_DEMAND_PRICE_MULTIPLIER = var.autospotting_on_demand_price_multiplier
PATCH_BEANSTALK_USERDATA = var.autospotting_patch_beanswalk_userdata
REGIONS = join(",", var.autospotting_regions_enabled)
SPOT_PRICE_BUFFER_PERCENTAGE = var.autospotting_spot_price_buffer_percentage
SPOT_PRODUCT_DESCRIPTION = var.autospotting_spot_product_description
SPOT_PRODUCT_PREMIUM = var.autospotting_spot_product_premium
SQS_QUEUE_URL = aws_sqs_queue.autospotting_fifo_queue.id
TAG_FILTERING_MODE = var.autospotting_tag_filtering_mode
TAG_FILTERS = var.autospotting_tag_filters
TERMINATION_NOTIFICATION_ACTION = var.autospotting_termination_notification_action
ALLOWED_INSTANCE_TYPES = var.autospotting_allowed_instance_types
BIDDING_POLICY = var.autospotting_bidding_policy
CRON_SCHEDULE = var.autospotting_cron_schedule
CRON_SCHEDULE_STATE = var.autospotting_cron_schedule_state
CRON_TIMEZONE = var.autospotting_cron_timezone
DISABLE_EVENT_BASED_INSTANCE_REPLACEMENT = var.autospotting_disable_event_based_instance_replacement
DISALLOWED_INSTANCE_TYPES = var.autospotting_disallowed_instance_types
EBS_GP2_CONVERSION_THRESHOLD = var.autospotting_ebs_gp2_conversion_threshold
INSTANCE_TERMINATION_METHOD = var.autospotting_instance_termination_method
LICENSE = var.autospotting_license
MIN_ON_DEMAND_NUMBER = var.autospotting_min_on_demand_number
MIN_ON_DEMAND_PERCENTAGE = var.autospotting_min_on_demand_percentage
ON_DEMAND_PRICE_MULTIPLIER = var.autospotting_on_demand_price_multiplier
PATCH_BEANSTALK_USERDATA = var.autospotting_patch_beanswalk_userdata
REGIONS = join(",", var.autospotting_regions_enabled)
SPOT_PRICE_BUFFER_PERCENTAGE = var.autospotting_spot_price_buffer_percentage
SPOT_PRODUCT_DESCRIPTION = var.autospotting_spot_product_description
SPOT_PRODUCT_PREMIUM = var.autospotting_spot_product_premium
SQS_QUEUE_URL = aws_sqs_queue.autospotting_fifo_queue.id
TAG_FILTERING_MODE = var.autospotting_tag_filtering_mode
TAG_FILTERS = var.autospotting_tag_filters
TERMINATION_NOTIFICATION_ACTION = var.autospotting_termination_notification_action
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions modules/lambda/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ variable "autospotting_bidding_policy" {}
variable "autospotting_cron_schedule_state" {}
variable "autospotting_cron_schedule" {}
variable "autospotting_cron_timezone" {}
variable "autospotting_disable_event_based_instance_replacement" {}
variable "autospotting_disallowed_instance_types" {}
variable "autospotting_ebs_gp2_conversion_threshold" {}
variable "autospotting_instance_termination_method" {}
variable "autospotting_license" {}
variable "autospotting_min_on_demand_number" {}
Expand Down
9 changes: 9 additions & 0 deletions modules/regional/resources/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}

module "label" {
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=0.21.0"
context = var.label_context
Expand Down
18 changes: 18 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ EOF
default = "UTC"
}

variable "autospotting_disable_event_based_instance_replacement" {
description = <<EOF
Disables the event based instance replacement, forcing AutoSpotting to run in legacy cron mode.
EOF
default = "false"
}

variable "autospotting_disallowed_instance_types" {
description = <<EOF
Comma separated list of disallowed instance types for spot requests,
Expand All @@ -65,6 +72,17 @@ EOF
default = ""
}

variable "autospotting_ebs_gp2_conversion_threshold" {
description = <<EOF
The EBS volume size below which to automatically replace GP2 EBS volumes
to the newer GP3 volume type, that's 20% cheaper and more performant than
GP2 for smaller sizes, but it's not getting more performant wth size as
GP2 does. Over 170 GB GP2 gets better throughput, and at 1TB GP2 also has
better IOPS than a baseline GP3 volume.
EOF
default = 170
}

variable "autospotting_instance_termination_method" {
description = <<EOF
Instance termination method. Must be one of 'autoscaling' (default) or
Expand Down

0 comments on commit 1836c81

Please sign in to comment.