Skip to content

Commit

Permalink
Merge pull request #6 from terra-mod/volumes
Browse files Browse the repository at this point in the history
Adds volume and daemon support
  • Loading branch information
k-k authored Jun 26, 2020
2 parents ecf24f1 + 0dfdc61 commit 598fb9e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
12 changes: 11 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ resource aws_ecs_task_definition task {
requires_compatibilities = var.task_requires_compatibilities

container_definitions = var.task_definition

dynamic "volume" {
for_each = var.task_volumes

content {
name = volume.value["name"]
host_path = volume.value["host_path"]
}
}
}

/**
Expand All @@ -111,14 +120,15 @@ resource aws_ecs_service service {
name = var.name
cluster = var.cluster_name
launch_type = var.launch_type
scheduling_strategy = var.scheduling_strategy
platform_version = var.platform_version
task_definition = aws_ecs_task_definition.task.arn
desired_count = var.desired_count
deployment_minimum_healthy_percent = var.deployment_minimum_healthy_percent
deployment_maximum_percent = var.deployment_maximum_percent

dynamic "ordered_placement_strategy" {
for_each = var.launch_type == "FARGATE" ? [] : [1]
for_each = var.launch_type == "FARGATE" || var.scheduling_strategy == "DAEMON" ? [] : [1]

content {
type = "spread"
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ variable launch_type {
default = "FARGATE"
}

variable scheduling_strategy {
description = "The scheduling strategy to use for the service. The valid values are REPLICA and DAEMON. Defaults to REPLICA. Note that Tasks using the Fargate launch type or the CODE_DEPLOY or EXTERNAL deployment controller types don't support the DAEMON scheduling strategy."
type = string
default = "REPLICA"
}

variable networking_subnets {
description = "The subnets for the Service."
type = list(string)
Expand Down Expand Up @@ -93,6 +99,12 @@ variable task_cpu {
default = 256
}

variable task_volumes {
description = "A set of volume blocks that containers in your task may use."
type = set(object({ name: string, host_path: string }))
default = []
}

variable cloudwatch_log_group_arn {
description = "If the service is expected to log to CloudWatch logs, specify the Log Group ARN. This is used to create the necessary IAM policy granting permission to write to that Log Group."
type = string
Expand Down

0 comments on commit 598fb9e

Please sign in to comment.