A Terraform primitive module that wraps the aws_efs_access_point resource, providing a consistent and validated interface for managing EFS Access Points.
A primitive module is a thin, focused Terraform wrapper around a single AWS resource type. Primitive modules:
- Wrap a single AWS resource (e.g.,
aws_efs_access_point) - Provide sensible defaults while maintaining full configurability
- Include comprehensive validation rules
- Follow consistent patterns for inputs, outputs, and tagging
- Include automated testing using Terratest
- Serve as building blocks for higher-level composite modules
This module creates an EFS Access Point that enforces a user identity and root directory for clients accessing an EFS file system. Access points simplify access management by:
- Enforcing a POSIX user identity for all connections
- Enforcing a root directory for the file system
- Enabling access control at the file system level
- Improving security through identity isolation
- POSIX User Enforcement: Optionally enforce a specific UID/GID for all file access
- Root Directory Configuration: Optionally enforce a specific directory as the root path
- Creation Info: Optionally configure owner and permissions for the root directory
- Comprehensive Tagging: Full support for resource tagging
- Flexible Configuration: All options are optional, supporting both simple and complex scenarios
- Validation: Input validation ensures correct configuration
Create a basic EFS access point with minimal configuration:
module "efs_access_point" {
source = "git::https://github.com/launchbynttdata/tf-aws-module_primitive-efs_access_point.git?ref=main"
efs_file_system_id = aws_efs_file_system.example.id
tags = {
Environment = "production"
Application = "myapp"
}
}Create an EFS access point with POSIX user and root directory enforcement:
module "efs_access_point" {
source = "git::https://github.com/launchbynttdata/tf-aws-module_primitive-efs_access_point.git?ref=main"
efs_file_system_id = aws_efs_file_system.example.id
posix_user = {
uid = 1000
gid = 1000
}
root_directory = {
path = "/app-data"
creation_info = {
owner_uid = 1000
owner_gid = 1000
permissions = "755"
}
}
tags = {
Environment = "production"
Application = "myapp"
}
}| Name | Description | Type | Default | Required |
|---|---|---|---|---|
efs_file_system_id |
The ID of the EFS file system | string |
n/a | yes |
posix_user |
POSIX user configuration for the access point | object({ uid = number, gid = number }) |
null |
no |
root_directory |
Root directory configuration for the access point | object({ path = string, creation_info = optional(...) }) |
null |
no |
name |
Name tag for the access point resource | string |
null |
no |
tags |
A map of tags to assign to the resource | map(string) |
{} |
no |
- Type:
string - Required: Yes
- Description: The ID of the EFS file system to which this access point will be attached
- Type:
object({ uid = number, gid = number }) - Default:
null - Description: POSIX user configuration. When set, enforces that all file system requests use the specified UID and GID
- Fields:
uid: The numeric user ID (UID)gid: The numeric group ID (GID)
- Type:
object({ path = string, creation_info = optional(object({ owner_uid = number, owner_gid = number, permissions = string })) }) - Default:
null - Description: Root directory configuration. When set, specifies a directory within the file system to serve as the root
- Fields:
path: The absolute path to the directory within the file system (e.g.,/data)creation_info(optional):owner_uid: The numeric UID to use for directory ownershipowner_gid: The numeric GID to use for directory ownershippermissions: The permission mode in octal format (e.g.,"755")
- Type:
map(string) - Default:
{} - Description: A map of tags to assign to the access point resource
- Special Tags: The module automatically adds a
ManagedBy = "Terraform"tag
- Type:
string - Default:
null - Description: Name tag for the access point resource. If provided, will be added as a 'Name' tag.
| Name | Description | Type |
|---|---|---|
access_point_id |
The ID of the EFS access point | string |
access_point_arn |
The ARN of the EFS access point | string |
- Terraform: >= 1.7
- AWS Provider: >= 5.100
module "basic_access_point" {
source = "git::https://github.com/launchbynttdata/tf-aws-module_primitive-efs_access_point.git?ref=main"
efs_file_system_id = aws_efs_file_system.main.id
tags = {
Environment = "dev"
Name = "basic-ap"
}
}module "app_user_access_point" {
source = "git::https://github.com/launchbynttdata/tf-aws-module_primitive-efs_access_point.git?ref=main"
efs_file_system_id = aws_efs_file_system.main.id
posix_user = {
uid = 1000
gid = 1000
}
tags = {
Environment = "prod"
Name = "app-user-ap"
}
}module "restricted_access_point" {
source = "git::https://github.com/launchbynttdata/tf-aws-module_primitive-efs_access_point.git?ref=main"
efs_file_system_id = aws_efs_file_system.main.id
root_directory = {
path = "/var/app/data"
creation_info = {
owner_uid = 500
owner_gid = 500
permissions = "700"
}
}
tags = {
Environment = "prod"
Name = "restricted-ap"
}
}See examples/complete/ for a full working example that demonstrates all features including file system creation.
See examples/simple/ for a quick-start example showing minimal configuration.
- Terraform >= 1.7
- AWS CLI configured with appropriate credentials
- Go 1.23 or later
makecommand
# Run all validation checks including formatting, linting, and Terratest
make check
# Run only Terratest functional tests
cd tests && go test ./...
# Run specific example tests
cd examples/simple && terraform plan -var-file=test.tfvars
cd examples/complete && terraform plan -var-file=test.tfvars-
POSIX User Enforcement: When
posix_useris configured, all file operations through the access point will use the specified UID/GID, preventing privilege escalation -
Root Directory Enforcement: When
root_directoryis configured, clients can only access files within the specified directory tree, preventing access to other file system areas -
File Permissions: Set appropriate
permissionsincreation_infoto control access to the root directory -
Access Control: Combine access points with appropriate IAM policies and security group rules to implement defense-in-depth
- The EFS file system must exist before creating an access point
- POSIX user IDs should be unique across your access points for clarity
- The root directory path must exist in the file system or be auto-created with the specified
creation_info - Access points are useful for multi-tenant scenarios where different users/applications need isolated access
- Consider using access points with Amazon EFS mount helpers for simplified setup
Please follow the established patterns in this module when contributing. All contributions should:
- Pass
make checkvalidation - Include appropriate examples if adding features
- Update documentation as needed
- Follow the Apache 2.0 license terms
This module is licensed under the Apache License 2.0. See LICENSE for details.
| Name | Version |
|---|---|
| terraform | ~> 1.7 |
| aws | ~> 5.100 |
No modules.
| Name | Type |
|---|---|
| aws_efs_access_point.this | resource |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| efs_file_system_id | The ID of the EFS file system | string |
n/a | yes |
| posix_user | A POSIX user identity block. Enforces a user identity for all file system requests made through the access point. | object({ |
null |
no |
| root_directory | A root directory block. Specifies the directory on the EFS file system that the access point provides access to. | object({ |
null |
no |
| name | Name tag for the access point resource. If provided, will be added as a 'Name' tag. | string |
n/a | yes |
| tags | A map of tags to assign to the EFS file system | map(string) |
{} |
no |
| Name | Description |
|---|---|
| access_point_id | The ID of the EFS access point |
| access_point_arn | Amazon Resource Name of the access point |
| file_system_id | The ID of the EFS file system that the access point applies to |
| owner_id | The AWS account ID that owns the access point resource |
| posix_user | The full POSIX identity, including the user ID, group ID, and secondary group IDs on the access point |
| root_directory | The directory on the EFS file system that the access point exposes as the root directory to NFS clients |
| tags | A map of tags assigned to the access point |