|
| 1 | +# Terraform AWS ARC EFS Module Usage Guide |
| 2 | + |
| 3 | +## Introduction |
| 4 | + |
| 5 | +### Purpose of the Document |
| 6 | + |
| 7 | +This document provides guidelines and instructions for users looking to implement the Terraform AWS ARC EFS module for creating and managing Amazon Elastic File System (EFS) resources. |
| 8 | + |
| 9 | +### Module Overview |
| 10 | + |
| 11 | +The Terraform AWS ARC EFS module provides a secure and modular foundation for deploying Amazon Elastic File System (EFS) on AWS. This module creates a fully-featured EFS file system with mount targets, security groups, access points, backup policies, and optional replication configuration. |
| 12 | + |
| 13 | +### Prerequisites |
| 14 | + |
| 15 | +Before using this module, ensure you have the following: |
| 16 | + |
| 17 | +- AWS credentials configured. |
| 18 | +- Terraform installed. |
| 19 | +- A working knowledge of AWS VPC, EFS, and Terraform concepts. |
| 20 | + |
| 21 | +## Getting Started |
| 22 | + |
| 23 | +### Module Source |
| 24 | + |
| 25 | +To use the module in your Terraform configuration, include the following source block: |
| 26 | + |
| 27 | +```hcl |
| 28 | +# Data sources for VPC resources |
| 29 | +data "aws_vpc" "default" { |
| 30 | + default = true |
| 31 | +} |
| 32 | +
|
| 33 | +data "aws_subnets" "private" { |
| 34 | + filter { |
| 35 | + name = "vpc-id" |
| 36 | + values = [data.aws_vpc.default.id] |
| 37 | + } |
| 38 | +
|
| 39 | + filter { |
| 40 | + name = "map-public-ip-on-launch" |
| 41 | + values = ["false"] |
| 42 | + } |
| 43 | +} |
| 44 | +
|
| 45 | +module "arc-efs" { |
| 46 | + source = "sourcefuse/arc-efs/aws" |
| 47 | + version = "1.0.0" |
| 48 | +
|
| 49 | + # Required variables |
| 50 | + namespace = "my-org" |
| 51 | + environment = "dev" |
| 52 | + name = "shared-storage" |
| 53 | +
|
| 54 | + # Mount targets configuration using data sources |
| 55 | + mount_targets = { |
| 56 | + "us-east-1a" = { subnet_id = data.aws_subnets.private.ids[0] } |
| 57 | + "us-east-1b" = { subnet_id = data.aws_subnets.private.ids[1] } |
| 58 | + } |
| 59 | +
|
| 60 | + # Security group configuration using data sources |
| 61 | + mount_target_security_group_vpc_id = data.aws_vpc.default.id |
| 62 | + allowed_cidr_blocks = [data.aws_vpc.default.cidr_block] |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +Refer to the [Terraform Registry](https://registry.terraform.io/modules/sourcefuse/arc-efs/aws/latest) for the latest version. |
| 67 | + |
| 68 | +### Integration with Existing Terraform Configurations |
| 69 | + |
| 70 | +To integrate the module with your existing Terraform mono repo configuration, follow the steps below: |
| 71 | + |
| 72 | +- Create a new folder in terraform/ named `efs`. |
| 73 | +- Create the required files, see the examples to base off of. |
| 74 | +- Configure with your backend: |
| 75 | + - Create the environment backend configuration file: config.<environment>.hcl |
| 76 | + - region: Where the backend resides |
| 77 | + - key: <working_directory>/terraform.tfstate |
| 78 | + - bucket: Bucket name where the terraform state will reside |
| 79 | + - dynamodb_table: Lock table so there are not duplicate tfplans in the mix |
| 80 | + - encrypt: Encrypt all traffic to and from the backend |
| 81 | + |
| 82 | +### Required AWS Permissions |
| 83 | + |
| 84 | +Ensure that the AWS credentials used to execute Terraform have the necessary permissions to create, list and modify: |
| 85 | + |
| 86 | +- EFS File Systems (`elasticfilesystem:*`) |
| 87 | +- EFS Mount Targets (`elasticfilesystem:CreateMountTarget`, `elasticfilesystem:DeleteMountTarget`) |
| 88 | +- EFS Access Points (`elasticfilesystem:CreateAccessPoint`, `elasticfilesystem:DeleteAccessPoint`) |
| 89 | +- EFS Backup Policies (`elasticfilesystem:PutBackupPolicy`, `elasticfilesystem:DeleteBackupPolicy`) |
| 90 | +- EFS File System Policies (`elasticfilesystem:PutFileSystemPolicy`, `elasticfilesystem:DeleteFileSystemPolicy`) |
| 91 | +- EFS Replication Configuration (`elasticfilesystem:CreateReplicationConfiguration`, `elasticfilesystem:DeleteReplicationConfiguration`) |
| 92 | +- VPC Security Groups (`ec2:CreateSecurityGroup`, `ec2:AuthorizeSecurityGroupIngress`, `ec2:AuthorizeSecurityGroupEgress`) |
| 93 | +- VPC Resources for validation (`ec2:DescribeVpcs`, `ec2:DescribeSubnets`, `ec2:DescribeSecurityGroups`) |
| 94 | + |
| 95 | +## Module Configuration |
| 96 | + |
| 97 | +### Input Variables |
| 98 | + |
| 99 | +For a complete list of input variables, see the README [Inputs](../../README.md#inputs) section. |
| 100 | + |
| 101 | +Key variables include: |
| 102 | +- `namespace`, `environment`, `name` - Required for resource naming |
| 103 | +- `mount_targets` - Configuration for EFS mount targets in different AZs |
| 104 | +- `performance_mode` - Either "generalPurpose" or "maxIO" |
| 105 | +- `throughput_mode` - "bursting", "elastic", or "provisioned" |
| 106 | +- `encrypted` - Enable encryption (default: true) |
| 107 | +- `access_points` - Configuration for EFS access points |
| 108 | +- `enable_backup_policy` - Enable automatic backups (default: true) |
| 109 | + |
| 110 | +### Output Values |
| 111 | + |
| 112 | +For a complete list of outputs, see the README [Outputs](../../README.md#outputs) section. |
| 113 | + |
| 114 | +Key outputs include: |
| 115 | +- `efs_id` - The EFS file system ID |
| 116 | +- `efs_dns_name` - DNS name for mounting the EFS |
| 117 | +- `mount_targets` - Information about created mount targets |
| 118 | +- `security_group_id` - ID of the created security group |
| 119 | +- `access_points` - Information about created access points |
| 120 | + |
| 121 | +## Module Usage |
| 122 | + |
| 123 | +### Basic Usage |
| 124 | + |
| 125 | +For basic usage, see the [examples](../../examples/) folder. |
| 126 | + |
| 127 | +This example will create: |
| 128 | + |
| 129 | +- An encrypted EFS file system with general purpose performance mode |
| 130 | +- Mount targets in specified availability zones |
| 131 | +- A security group allowing NFS access from specified CIDR blocks |
| 132 | +- Optional access points for fine-grained access control |
| 133 | +- Backup policy (enabled by default) |
| 134 | + |
| 135 | +### Tips and Recommendations |
| 136 | + |
| 137 | +- The module focuses on provisioning a secure, scalable EFS file system. The convention-based approach enables downstream services to easily mount the EFS file system. Adjust the configuration parameters as needed for your specific use case. |
| 138 | +- Use data sources to dynamically fetch VPC and subnet information instead of hardcoding values for better reusability |
| 139 | +- Use multiple mount targets across different AZs for high availability |
| 140 | +- Prefer private subnets for EFS mount targets for better security |
| 141 | +- Consider using access points for applications requiring different permissions or directory structures |
| 142 | +- Enable encryption at rest and in transit for sensitive data |
| 143 | +- Configure appropriate security group rules to limit access to your EFS file system |
| 144 | + |
| 145 | +## Troubleshooting |
| 146 | + |
| 147 | +### Reporting Issues |
| 148 | + |
| 149 | +If you encounter a bug or issue, please report it on the [GitHub repository](https://github.com/sourcefuse/terraform-aws-arc-efs/issues). |
| 150 | + |
| 151 | +## Security Considerations |
| 152 | + |
| 153 | +### AWS VPC |
| 154 | + |
| 155 | +Understand the security considerations related to Amazon EFS on AWS when using this module: |
| 156 | + |
| 157 | +- EFS file systems are accessible within the VPC through mount targets |
| 158 | +- Mount targets create network interfaces in your subnets with private IP addresses |
| 159 | +- Security groups control access to mount targets at the network level |
| 160 | +- EFS supports encryption in transit using TLS and encryption at rest using AWS KMS |
| 161 | + |
| 162 | +### Best Practices for AWS EFS |
| 163 | + |
| 164 | +Follow best practices to ensure secure EFS configurations: |
| 165 | + |
| 166 | +- [AWS EFS Security Best Practices](https://docs.aws.amazon.com/efs/latest/ug/security-considerations.html) |
| 167 | +- Enable encryption at rest using AWS KMS keys for sensitive data |
| 168 | +- Use IAM policies and EFS access points to control file-level access |
| 169 | +- Implement least-privilege access through security groups |
| 170 | +- Monitor EFS access using AWS CloudTrail and VPC Flow Logs |
| 171 | +- Use backup policies to protect against data loss |
| 172 | +- Consider cross-region replication for disaster recovery |
| 173 | + |
| 174 | +## Contributing and Community Support |
| 175 | + |
| 176 | +### Contributing Guidelines |
| 177 | + |
| 178 | +Contribute to the module by following the guidelines outlined in the [CONTRIBUTING.md](../../CONTRIBUTING.md) file. |
| 179 | + |
| 180 | +### Reporting Bugs and Issues |
| 181 | + |
| 182 | +If you find a bug or issue, report it on the [GitHub repository](https://github.com/sourcefuse/terraform-aws-arc-efs/issues). |
| 183 | + |
| 184 | +## License |
| 185 | + |
| 186 | +### License Information |
| 187 | + |
| 188 | +This module is licensed under the Apache 2.0 license. Refer to the [LICENSE](../../LICENSE) file for more details. |
| 189 | + |
| 190 | +### Open Source Contribution |
| 191 | + |
| 192 | +Contribute to open source by using and enhancing this module. Your contributions are welcome! |
0 commit comments