Skip to content

Commit

Permalink
support extra template variables for custom sfn (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
morsecodist authored May 4, 2022
1 parent ef49c95 commit c45426c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 13 deletions.
9 changes: 6 additions & 3 deletions terraform/modules/swipe-sfn/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,15 @@ module "sfn_io_helper" {

resource "aws_sfn_state_machine" "swipe_single_wdl" {
for_each = merge(var.sfn_template_files, {
"default" : "${path.module}/default-wdl.yml",
"default" : {
path = "${path.module}/default-wdl.yml"
extra_template_vars = {}
}
})

name = "${var.app_name}-${each.key}-wdl"
role_arn = aws_iam_role.swipe_sfn_service.arn
definition = jsonencode(yamldecode(templatefile(each.value, {
definition = jsonencode(yamldecode(templatefile(each.value.path, merge({
batch_spot_job_queue_arn = var.batch_spot_job_queue_arn,
batch_on_demand_job_queue_arn = var.batch_on_demand_job_queue_arn,
batch_job_definition_name = module.batch_job.batch_job_definition_name,
Expand All @@ -79,6 +82,6 @@ resource "aws_sfn_state_machine" "swipe_single_wdl" {
process_stage_output_lambda_name = module.sfn_io_helper.process_stage_output_lambda_name,
handle_success_lambda_name = module.sfn_io_helper.handle_success_lambda_name,
handle_failure_lambda_name = module.sfn_io_helper.handle_failure_lambda_name,
})))
}, each.value.extra_template_vars))))
tags = var.tags
}
9 changes: 5 additions & 4 deletions terraform/modules/swipe-sfn/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ variable "app_name" {
variable "aws_endpoint_url" {
type = string
description = "Override the AWS endpoint URL used by lambda functions"
default = null
}

variable "sfn_template_files" {
description = "A map of names to YAML AWS Step Function State Machine Definition Templates. To be used with multi-stage workflows, see documentation on multi-stage workflows for more information"
type = map(string)
description = "A map of names to YAML AWS Step Function State Machine Definition Templates. Useful for multi-stage workflows or custom compute environments, see documentation on multi-stage workflows for more information"
type = map(object({
path = string
extra_template_vars = map(string)
}))
}

variable "job_policy_arns" {
Expand Down Expand Up @@ -71,7 +73,6 @@ variable "tags" {
variable "docker_network" {
description = "If miniwdl's task containers should be attached to a specific docker network, set the network name here"
type = string
default = ""
}

// Module Specific
Expand Down
5 changes: 4 additions & 1 deletion test/terraform/localstack/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ module "swipetest" {
"notifications" : { "dead_letter" : false }
}
sfn_template_files = {
"stage-test" : "../../stage-test.yml"
"stage-test" : {
path = "../../stage-test.yml"
extra_template_vars = {}
}
}
stage_memory_defaults = {
"Run" : { "spot" : 12800, "on_demand" : 256000 },
Expand Down
5 changes: 4 additions & 1 deletion test/terraform/moto/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ module "swipetest" {
"notifications" : { "dead_letter" : false }
}
sfn_template_files = {
"stage-test" : "../../stage-test.yml"
"stage-test" : {
path = "../../stage-test.yml"
extra_template_vars = {}
}
}
stage_memory_defaults = {
"Run" : { "spot" : 12800, "on_demand" : 256000 },
Expand Down
9 changes: 6 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ variable "on_demand_max_vcpus" {
}

variable "sfn_template_files" {
description = "A map of names to YAML AWS Step Function State Machine Definition Templates. To be used with multi-stage workflows, see documentation on multi-stage workflows for more information"
type = map(string)
default = {}
description = "A map of names to YAML AWS Step Function State Machine Definition Templates. Useful for multi-stage workflows or custom compute environments, see documentation on multi-stage workflows for more information"
type = map(object({
path = string
extra_template_vars = map(string)
}))

}

variable "job_policy_arns" {
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.19.5-beta
v0.20.0-beta

0 comments on commit c45426c

Please sign in to comment.