Skip to content

Commit

Permalink
Support vcpu configuration (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
morsecodist authored Dec 19, 2021
1 parent 002602c commit 434ea69
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module "sfn" {
job_policy_arns = var.job_policy_arns
sfn_template_files = var.sfn_template_files
stage_memory_defaults = var.stage_memory_defaults
stage_vcpu_defaults = var.stage_vcpu_defaults
extra_env_vars = var.extra_env_vars
tags = var.tags
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,7 @@ def preprocess_sfn_input(sfn_state, aws_region, aws_account_id, state_machine_na
for compute_env in "SPOT", "EC2":
memory_key = stage + compute_env + "Memory"
sfn_state.setdefault(memory_key, int(os.environ[memory_key + "Default"]))
vcpu_key = stage + compute_env + "Vcpu"
sfn_state.setdefault(vcpu_key, int(os.environ[vcpu_key + "Default"]))

return sfn_state
5 changes: 5 additions & 0 deletions terraform/modules/sfn-io-helper-lambdas/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,12 @@ resource "aws_lambda_function" "lambda" {
for stage, defaults in var.stage_memory_defaults : "${stage}SPOTMemoryDefault" => "${defaults.spot}"
}, {
for stage, defaults in var.stage_memory_defaults : "${stage}EC2MemoryDefault" => "${defaults.on_demand}"
}, {
for stage, defaults in var.stage_vcpu_defaults : "${stage}SPOTVcpuDefault" => "${defaults.spot}"
}, {
for stage, defaults in var.stage_vcpu_defaults : "${stage}EC2VcpuDefault" => "${defaults.on_demand}"
},

)
}
}
Expand Down
7 changes: 7 additions & 0 deletions terraform/modules/sfn-io-helper-lambdas/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,10 @@ variable "stage_memory_defaults" {
}))
}

variable "stage_vcpu_defaults" {
type = map(object({
on_demand = number,
spot = number,
}))
}

1 change: 1 addition & 0 deletions terraform/modules/swipe-sfn/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module "sfn_io_helper" {
workspace_s3_prefix = var.workspace_s3_prefix
wdl_workflow_s3_prefix = var.wdl_workflow_s3_prefix
stage_memory_defaults = var.stage_memory_defaults
stage_vcpu_defaults = var.stage_vcpu_defaults
tags = var.tags
}

Expand Down
7 changes: 7 additions & 0 deletions terraform/modules/swipe-sfn/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ variable "stage_memory_defaults" {
}))
}

variable "stage_vcpu_defaults" {
type = map(object({
on_demand = number,
spot = number,
}))
}

variable "extra_env_vars" {
description = "Additional env vars to set on batch task definitions"
type = map(string)
Expand Down
14 changes: 14 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ variable "stage_memory_defaults" {
}
}

variable "stage_vcpu_defaults" {
type = map(object({
on_demand = number,
spot = number,
}))

default = {
"Run" : {
on_demand = 2,
spot = 2,
}
}
}

variable "extra_env_vars" {
description = "Additional env vars to set on batch task definitions"
type = map(string)
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.5.1-beta
v0.6.0-beta

0 comments on commit 434ea69

Please sign in to comment.