Home

Awesome

AWS EFS Terraform module

Terraform module which creates AWS EFS (elastic file system) resources.

SWUbanner

Usage

See examples directory for working examples to reference:

module "efs" {
  source = "terraform-aws-modules/efs/aws"

  # File system
  name           = "example"
  creation_token = "example-token"
  encrypted      = true
  kms_key_arn    = "arn:aws:kms:eu-west-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"

  # performance_mode                = "maxIO"
  # NB! PROVISIONED TROUGHPUT MODE WITH 256 MIBPS IS EXPENSIVE ~$1500/month
  # throughput_mode                 = "provisioned"
  # provisioned_throughput_in_mibps = 256

  lifecycle_policy = {
    transition_to_ia = "AFTER_30_DAYS"
  }

  # File system policy
  attach_policy                      = true
  bypass_policy_lockout_safety_check = false
  policy_statements = [
    {
      sid     = "Example"
      actions = ["elasticfilesystem:ClientMount"]
      principals = [
        {
          type        = "AWS"
          identifiers = ["arn:aws:iam::111122223333:role/EfsReadOnly"]
        }
      ]
    }
  ]

  # Mount targets / security group
  mount_targets = {
    "eu-west-1a" = {
      subnet_id = "subnet-abcde012"
    }
    "eu-west-1b" = {
      subnet_id = "subnet-bcde012a"
    }
    "eu-west-1c" = {
      subnet_id = "subnet-fghi345a"
    }
  }
  security_group_description = "Example EFS security group"
  security_group_vpc_id      = "vpc-1234556abcdef"
  security_group_rules = {
    vpc = {
      # relying on the defaults provdied for EFS/NFS (2049/TCP + ingress)
      description = "NFS ingress from VPC private subnets"
      cidr_blocks = ["10.99.3.0/24", "10.99.4.0/24", "10.99.5.0/24"]
    }
  }

  # Access point(s)
  access_points = {
    posix_example = {
      name = "posix-example"
      posix_user = {
        gid            = 1001
        uid            = 1001
        secondary_gids = [1002]
      }

      tags = {
        Additionl = "yes"
      }
    }
    root_example = {
      root_directory = {
        path = "/example"
        creation_info = {
          owner_gid   = 1001
          owner_uid   = 1001
          permissions = "755"
        }
      }
    }
  }

  # Backup policy
  enable_backup_policy = true

  # Replication configuration
  create_replication_configuration = true
  replication_configuration_destination = {
    region = "eu-west-2"
  }

  tags = {
    Terraform   = "true"
    Environment = "dev"
  }
}

Examples

Examples codified under the examples are intended to give users references for how to use the module(s) as well as testing/validating changes to the source code of the module. If contributing to the project, please be sure to make any appropriate updates to the relevant examples to allow maintainers to test your changes and to keep the examples up to date for users. Thank you!

<!-- BEGIN_TF_DOCS -->

Requirements

NameVersion
<a name="requirement_terraform"></a> terraform>= 1.0
<a name="requirement_aws"></a> aws>= 5.35

Providers

NameVersion
<a name="provider_aws"></a> aws>= 5.35

Modules

No modules.

Resources

NameType
aws_efs_access_point.thisresource
aws_efs_backup_policy.thisresource
aws_efs_file_system.thisresource
aws_efs_file_system_policy.thisresource
aws_efs_mount_target.thisresource
aws_efs_replication_configuration.thisresource
aws_security_group.thisresource
aws_security_group_rule.thisresource
aws_iam_policy_document.policydata source

Inputs

NameDescriptionTypeDefaultRequired
<a name="input_access_points"></a> access_pointsA map of access point definitions to createany{}no
<a name="input_attach_policy"></a> attach_policyDetermines whether a policy is attached to the file systembooltrueno
<a name="input_availability_zone_name"></a> availability_zone_nameThe AWS Availability Zone in which to create the file system. Used to create a file system that uses One Zone storage classesstringnullno
<a name="input_bypass_policy_lockout_safety_check"></a> bypass_policy_lockout_safety_checkA flag to indicate whether to bypass the aws_efs_file_system_policy lockout safety check. Defaults to falseboolnullno
<a name="input_create"></a> createDetermines whether resources will be created (affects all resources)booltrueno
<a name="input_create_backup_policy"></a> create_backup_policyDetermines whether a backup policy is createdbooltrueno
<a name="input_create_replication_configuration"></a> create_replication_configurationDetermines whether a replication configuration is createdboolfalseno
<a name="input_create_security_group"></a> create_security_groupDetermines whether a security group is createdbooltrueno
<a name="input_creation_token"></a> creation_tokenA unique name (a maximum of 64 characters are allowed) used as reference when creating the Elastic File System to ensure idempotent file system creation. By default generated by Terraformstringnullno
<a name="input_deny_nonsecure_transport"></a> deny_nonsecure_transportDetermines whether aws:SecureTransport is required when connecting to elastic file systembooltrueno
<a name="input_enable_backup_policy"></a> enable_backup_policyDetermines whether a backup policy is ENABLED or DISABLEDbooltrueno
<a name="input_encrypted"></a> encryptedIf true, the disk will be encryptedbooltrueno
<a name="input_kms_key_arn"></a> kms_key_arnThe ARN for the KMS encryption key. When specifying kms_key_arn, encrypted needs to be set to truestringnullno
<a name="input_lifecycle_policy"></a> lifecycle_policyA file system lifecycle policy objectany{}no
<a name="input_mount_targets"></a> mount_targetsA map of mount target definitions to createany{}no
<a name="input_name"></a> nameThe name of the file systemstring""no
<a name="input_override_policy_documents"></a> override_policy_documentsList of IAM policy documents that are merged together into the exported document. In merging, statements with non-blank sids will override statements with the same sidlist(string)[]no
<a name="input_performance_mode"></a> performance_modeThe file system performance mode. Can be either generalPurpose or maxIO. Default is generalPurposestringnullno
<a name="input_policy_statements"></a> policy_statementsA list of IAM policy statements for custom permission usageany[]no
<a name="input_provisioned_throughput_in_mibps"></a> provisioned_throughput_in_mibpsThe throughput, measured in MiB/s, that you want to provision for the file system. Only applicable with throughput_mode set to provisionednumbernullno
<a name="input_replication_configuration_destination"></a> replication_configuration_destinationA destination configuration blockany{}no
<a name="input_security_group_description"></a> security_group_descriptionSecurity group description. Defaults to Managed by Terraformstringnullno
<a name="input_security_group_name"></a> security_group_nameName to assign to the security group. If omitted, Terraform will assign a random, unique namestringnullno
<a name="input_security_group_rules"></a> security_group_rulesMap of security group rule definitions to createany{}no
<a name="input_security_group_use_name_prefix"></a> security_group_use_name_prefixDetermines whether to use a name prefix for the security group. If true, the security_group_name value will be used as a prefixboolfalseno
<a name="input_security_group_vpc_id"></a> security_group_vpc_idThe VPC ID where the security group will be createdstringnullno
<a name="input_source_policy_documents"></a> source_policy_documentsList of IAM policy documents that are merged together into the exported document. Statements must have unique sidslist(string)[]no
<a name="input_tags"></a> tagsA map of tags to add to all resourcesmap(string){}no
<a name="input_throughput_mode"></a> throughput_modeThroughput mode for the file system. Defaults to bursting. Valid values: bursting, elastic, and provisioned. When using provisioned, also set provisioned_throughput_in_mibpsstringnullno

Outputs

NameDescription
<a name="output_access_points"></a> access_pointsMap of access points created and their attributes
<a name="output_arn"></a> arnAmazon Resource Name of the file system
<a name="output_dns_name"></a> dns_nameThe DNS name for the filesystem per documented convention
<a name="output_id"></a> idThe ID that identifies the file system (e.g., fs-ccfc0d65)
<a name="output_mount_targets"></a> mount_targetsMap of mount targets created and their attributes
<a name="output_replication_configuration_destination_file_system_id"></a> replication_configuration_destination_file_system_idThe file system ID of the replica
<a name="output_security_group_arn"></a> security_group_arnARN of the security group
<a name="output_security_group_id"></a> security_group_idID of the security group
<a name="output_size_in_bytes"></a> size_in_bytesThe latest known metered size (in bytes) of data stored in the file system, the value is not the exact size that the file system was at any point in time
<!-- END_TF_DOCS -->

License

Apache-2.0 Licensed. See LICENSE.