
terraform-aws-arc-efs¶
Overview¶
SourceFuse AWS Reference Architecture (ARC) Terraform module for managing AWS Elastic File System.
Usage¶
Basic Example¶
Advanced Example with Access Points¶
Examples¶
This module includes several comprehensive examples:
- Basic - Simple EFS setup with mount targets
- With Access Points - Multiple access points for different applications
- With Replication - Cross-region replication for disaster recovery
- Complete - All features including encryption, lifecycle policies, and access points
Important Notes¶
EFS Replication Cleanup Behavior¶
Important: When using cross-region EFS replication (replication_configuration), AWS creates a destination EFS file system in the target region. By AWS design, when replication is deleted (e.g., during terraform destroy), the destination EFS is preserved as a standalone, writeable file system rather than being automatically deleted.
This is an AWS safety feature to prevent accidental data loss, but it means the destination EFS will continue to incur charges unless manually cleaned up.
To avoid ongoing charges:
1. After running terraform destroy, manually check the destination region (e.g., us-east-2)
2. Delete any remaining EFS file systems that were created by replication if you no longer need them
3. You can identify these by their creation time matching when you deployed your Terraform configuration
Example cleanup commands:
Why this happens: According to AWS documentation: "Deleting a replication configuration ends the replication process. After a replication configuration is deleted, the destination file system becomes Writeable and its replication overwrite protection is re-enabled."
This behavior ensures that valuable data in the destination EFS is not accidentally lost when replication is stopped.
Requirements¶
| Name | Version |
|---|---|
| terraform | >= 1.3 |
| aws | >= 5.0, < 7.0 |
Providers¶
| Name | Version |
|---|---|
| aws | 6.25.0 |
Modules¶
No modules.
Resources¶
| Name | Type |
|---|---|
| aws_efs_access_point.this | resource |
| aws_efs_backup_policy.this | resource |
| aws_efs_file_system.this | resource |
| aws_efs_file_system_policy.this | resource |
| aws_efs_mount_target.this | resource |
| aws_efs_replication_configuration.this | resource |
| aws_security_group.mount_target | resource |
| aws_security_group_rule.additional | resource |
| aws_security_group_rule.nfs_ingress_cidr | resource |
| aws_security_group_rule.nfs_ingress_sg | resource |
Inputs¶
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| access_points | A map of EFS access points to create | map(object({ |
{} |
no |
| additional_security_group_rules | A map of additional security group rules to add to the mount target security group | map(object({ |
{} |
no |
| allowed_cidr_blocks | List of CIDR blocks allowed to access EFS | list(string) |
[] |
no |
| allowed_security_group_ids | List of security group IDs allowed to access EFS | list(string) |
[] |
no |
| availability_zone_name | AWS Availability Zone in which to create the file system. Used to create a file system that uses One Zone storage classes | string |
null |
no |
| bypass_policy_lockout_safety_check | A flag to indicate whether to bypass the aws_efs_file_system_policy lockout safety check | bool |
false |
no |
| create_mount_target_security_group | Create a security group for mount targets | bool |
true |
no |
| creation_token | A unique name (a maximum of 64 characters are allowed) used as reference when creating the EFS | string |
null |
no |
| enable_backup_policy | A boolean that indicates whether or not to apply Backup Policy to the file system | bool |
true |
no |
| encrypted | If true, the disk will be encrypted | bool |
true |
no |
| kms_key_id | The ARN for the KMS encryption key. When specifying kms_key_id, encrypted needs to be set to true | string |
null |
no |
| lifecycle_policy | A file system lifecycle policy object | object({ |
{} |
no |
| mount_target_security_group_description | Description of the mount target security group | string |
"EFS mount target security group" |
no |
| mount_target_security_group_name | Name of the mount target security group | string |
null |
no |
| mount_target_security_group_vpc_id | ID of the VPC where mount target security group will be created | string |
null |
no |
| mount_targets | A map of mount target configurations where key is the AZ name | map(object({ |
{} |
no |
| name | Name of the EFS file system | string |
n/a | yes |
| performance_mode | The file system performance mode. Can be either generalPurpose or maxIO |
string |
"generalPurpose" |
no |
| policy | A valid JSON formatted policy for the EFS file system | string |
null |
no |
| provisioned_throughput_in_mibps | The throughput, measured in MiB/s, that you want to provision for the file system. Only applicable with throughput_mode set to provisioned | number |
null |
no |
| replication_configuration | A map of replication configuration | object({ |
null |
no |
| tags | Additional tags (e.g. {'BusinessUnit': 'XYZ'}) |
map(string) |
{} |
no |
| throughput_mode | Throughput mode for the file system. Defaults to bursting. Valid values: bursting, elastic, provisioned |
string |
"bursting" |
no |
Outputs¶
| Name | Description |
|---|---|
| access_point_arns | List of access point ARNs |
| access_point_ids | List of access point IDs |
| access_points | Map of access points created |
| backup_policy_id | ID of the backup policy |
| complete_efs_config | Complete EFS configuration for reference |
| efs_arn | ARN of the EFS file system |
| efs_creation_token | Creation token of the EFS file system |
| efs_dns_name | DNS name of the EFS file system |
| efs_encrypted | Whether the EFS file system is encrypted |
| efs_id | ID of the EFS file system |
| efs_kms_key_id | The ARN for the KMS encryption key used to encrypt the EFS file system |
| efs_owner_id | AWS account ID that created the file system |
| efs_performance_mode | Performance mode of the EFS file system |
| efs_size_in_bytes | Current byte count used by the file system |
| efs_throughput_mode | Throughput mode of the EFS file system |
| mount_target_dns_names | List of mount target DNS names |
| mount_target_ids | List of mount target IDs |
| mount_target_network_interface_ids | List of mount target network interface IDs |
| mount_targets | Map of mount targets created |
| replication_configuration_destination_file_system_id | The file system ID of the replica |
| replication_configuration_id | ID of the replication configuration |
| security_group_arn | ARN of the mount target security group |
| security_group_id | ID of the mount target security group |
| security_group_name | Name of the mount target security group |
Versioning¶
This project uses a .version file at the root of the repo which the pipeline reads from and does a git tag.
When you intend to commit to main, you will need to increment this version. Once the project is merged,
the pipeline will kick off and tag the latest git commit.
Development¶
Prerequisites¶
Configurations¶
- Configure pre-commit hooks
Versioning¶
while Contributing or doing git commit please specify the breaking change in your commit message whether its major,minor or patch
For Example
Tests¶
- Tests are available in
testdirectory - Configure the dependencies
- Now execute the test
Authors¶
This project is authored by: - SourceFuse ARC Team