Skip to content

Commit 9b90317

Browse files
authored
Merge pull request #350 from trussworks/optionally-enable-efs
feat: enable use of efs volumes from ecs task definition
2 parents 4a9173e + 4673588 commit 9b90317

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ No modules.
157157
| cloudwatch\_alarm\_name | Generic name used for CPU and Memory Cloudwatch Alarms | `string` | `""` | no |
158158
| container\_definitions | Container definitions provided as valid JSON document. Default uses golang:alpine running a simple hello world. | `string` | `""` | no |
159159
| container\_image | The image of the container. | `string` | `"golang:alpine"` | no |
160-
| container\_volumes | Volumes that containers in your task may use. | ```list( object({ name = string }) )``` | `[]` | no |
160+
| container\_volumes | Volumes that containers in your task may use. | `list` | `[]` | no |
161161
| ec2\_create\_task\_execution\_role | Set to true to create ecs task execution role to ECS EC2 Tasks. | `bool` | `false` | no |
162162
| ecr\_repo\_arns | The ARNs of the ECR repos. By default, allows all repositories. | `list(string)` | ```[ "*" ]``` | no |
163163
| ecs\_cluster | ECS cluster object for this task. | ```object({ arn = string name = string })``` | n/a | yes |
@@ -167,6 +167,7 @@ No modules.
167167
| ecs\_subnet\_ids | Subnet IDs for the ECS tasks. | `list(string)` | n/a | yes |
168168
| ecs\_use\_fargate | Whether to use Fargate for the task definition. | `bool` | `false` | no |
169169
| ecs\_vpc\_id | VPC ID to be used by ECS. | `string` | n/a | yes |
170+
| efs\_instance\_id | ID of the EFS instance volume | `string` | `""` | no |
170171
| enable\_ecs\_managed\_tags | Specifies whether to enable Amazon ECS managed tags for the tasks within the service | `bool` | `false` | no |
171172
| environment | Environment tag, e.g prod. | `string` | n/a | yes |
172173
| fargate\_platform\_version | The platform version on which to run your service. Only applicable when using Fargate launch type. | `string` | `"LATEST"` | no |

main.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,21 @@ resource "aws_ecs_task_definition" "main" {
441441
for_each = var.container_volumes
442442
content {
443443
name = volume.value.name
444+
dynamic "efs_volume_configuration" {
445+
for_each = try([volume.value.efs_volume_configuration], [])
446+
447+
content {
448+
authorization_config {
449+
access_point_id = try(efs_volume_configuration.value.access_point_id, null)
450+
iam = try(efs_volume_configuration.value.iam, "ENABLED")
451+
}
452+
453+
file_system_id = var.efs_instance_id
454+
root_directory = try(efs_volume_configuration.value.root_directory, "/")
455+
transit_encryption = try(efs_volume_configuration.value.transit_encryption, "ENABLED")
456+
transit_encryption_port = try(efs_volume_configuration.value.transit_encryption_port, null)
457+
}
458+
}
444459
}
445460
}
446461

variables.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,6 @@ variable "lb_target_groups" {
209209
variable "container_volumes" {
210210
description = "Volumes that containers in your task may use."
211211
default = []
212-
type = list(
213-
object({
214-
name = string
215-
})
216-
)
217-
218212
}
219213

220214
variable "hello_world_container_ports" {
@@ -269,3 +263,9 @@ variable "ecs_deployment_circuit_breaker" {
269263
rollback = false
270264
}
271265
}
266+
267+
variable "efs_instance_id" {
268+
description = "ID of the EFS instance volume"
269+
type = string
270+
default = ""
271+
}

0 commit comments

Comments
 (0)