Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: add support for EFS File System Config
  • Loading branch information
niranjan94 committed Aug 13, 2020
commit 4b784729ce61bd05d0e13b254ea0125587d3a7a3
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@ Q4: What does this error mean - `"We currently do not support adding policies fo
| docker\_pip\_cache | Whether to mount a shared pip cache folder into docker environment or not | `any` | `null` | no |
| docker\_with\_ssh\_agent | Whether to pass SSH\_AUTH\_SOCK into docker environment or not | `bool` | `false` | no |
| environment\_variables | A map that defines environment variables for the Lambda Function. | `map(string)` | `{}` | no |
| file\_system\_arn | The Amazon Resource Name (ARN) of the Amazon EFS Access Point that provides access to the file system. | `string` | `null` | no |
| file\_system\_local\_mount\_path | The path where the function can access the file system, starting with /mnt/. | `string` | `null` | no |
| function\_name | A unique name for your Lambda Function | `string` | `""` | no |
| handler | Lambda Function entrypoint in your code | `string` | `""` | no |
| hash\_extra | The string to add into hashing function. Useful when building same source path for different functions. | `string` | `""` | no |
Expand Down
29 changes: 29 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ module "lambda_function" {
}
}


######################
# Elastic File System
######################

file_system_arn = aws_efs_access_point.lambda.arn
file_system_local_mount_path = "/mnt/shared-storage/"

######################
# Additional policies
######################
Expand Down Expand Up @@ -233,6 +241,27 @@ module "s3_bucket" {
force_destroy = true
}

resource "aws_efs_file_system" "shared" {}

resource "aws_efs_access_point" "lambda" {
file_system_id = aws_efs_file_system.shared.id

posix_user {
gid = 1000
uid = 1000
}

root_directory {
path = "/lambda"
creation_info {
owner_gid = 1000
owner_uid = 1000
permissions = "0777"
}
}
}


resource "aws_sqs_queue" "dlq" {
name = random_pet.this.id
}
8 changes: 8 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ resource "aws_lambda_function" "this" {
}
}

dynamic "file_system_config" {
for_each = var.file_system_arn != null && var.file_system_local_mount_path != null ? [true] : []
content {
local_mount_path = var.file_system_local_mount_path
arn = var.file_system_arn
}
}

tags = var.tags

depends_on = [null_resource.archive, aws_s3_bucket_object.lambda_package]
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,18 @@ variable "policy_statements" {
default = {}
}

variable "file_system_arn" {
description = "The Amazon Resource Name (ARN) of the Amazon EFS Access Point that provides access to the file system."
type = string
default = null
}

variable "file_system_local_mount_path" {
description = "The path where the function can access the file system, starting with /mnt/."
type = string
default = null
}

##########################
# Build artifact settings
##########################
Expand Down