Skip to content

Commit

Permalink
Add non-persistent volume support
Browse files Browse the repository at this point in the history
This adds a 'volumes' variable that can drive the 'volume' nested config block.
For now, we'll only add support for non-persistent volumes,
but this can be easily changed later on.
  • Loading branch information
mattdrees committed Jul 4, 2020
1 parent 9bcaab6 commit e76e0cd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ module "ecs_scheduled_task" {
create_ecs_task_execution_role = false
ecs_task_execution_role_arn = aws_iam_role.ecs_task_execution.arn

volumes = [{
name = "example-volume"
}]

tags = {
Environment = "prod"
}
Expand Down
9 changes: 9 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ resource "aws_ecs_task_definition" "default" {
# https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#network_mode
network_mode = "awsvpc"

# The docker volumes that the task will make available to its containers.
# https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#volumes
dynamic "volume" {
for_each = var.volumes
content {
name = volume.key.name
}
}

# A mapping of tags to assign to the resource.
tags = merge({ "Name" = var.name }, var.tags)
}
Expand Down
8 changes: 8 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,11 @@ variable "ecs_task_execution_role_arn" {
type = string
description = "The ARN of the ECS Task Execution IAM Role."
}

variable "volumes" {
default = []
type = set(object({
name = string
}))
description = "The non-persistent data volumes to be used by the task."
}

0 comments on commit e76e0cd

Please sign in to comment.