Amazon Elastic File System
User Guide

Step 2: Create Amazon EFS Resources

In this step, you do the following:

  • Create an Amazon EFS file system.

  • Enable lifecycle management.

  • Create a mount target in the Availability Zone where you have your EC2 instance launched.

Step 2.1: Create Amazon EFS File System

In this step, you create an Amazon EFS file system. Write down the FileSystemId to use later when you create mount targets for the file system in the next step.

To create a file system

  • Create a file system with the optional Name tag.

    1. At the command prompt, run the following AWS CLI create-file-system command.

      $ aws efs create-file-system \ --creation-token FileSystemForWalkthrough1 \ --tags Key=Name,Value=SomeExampleNameValue \ --region us-west-2 \ --profile adminuser

      You get the following response.

      { "OwnerId": "123456789abcd", "CreationToken": "FileSystemForWalkthrough1", "FileSystemId": "fs-c657c8bf", "CreationTime": 1548950706.0, "LifeCycleState": "creating", "NumberOfMountTargets": 0, "SizeInBytes": { "Value": 0, "ValueInIA": 0, "ValueInStandard": 0 }, "PerformanceMode": "generalPurpose", "Encrypted": false, "ThroughputMode": "bursting", "Tags": [ { "Key": "Name", "Value": "SomeExampleNameValue" } ] }
    2. Note the FileSystemId value. You need this value when you create a mount target for this file system in Step 2.3: Create a Mount Target.

Step 2.2: Enable Lifecycle Management

In this step, you enable lifecycle management on your file system in order to use the Infrequent Access storage class. To learn more, see EFS Lifecycle Management and EFS Storage Classes.

To enable lifecycle management

  • At the command prompt, run the following AWS CLI put-lifecycle-configuration command.

    $ aws efs put-lifecycle-configuration \ --file-system-id fs-c657c8bf \ --lifecycle-policies TransitionToIA=AFTER_30_DAYS \ --region us-west-2 \ --profile adminuser

    You get the following response.

    { "LifecyclePolicies": [ { "TransitionToIA": "AFTER_30_DAYS" } ] }

Step 2.3: Create a Mount Target

In this step, you create a mount target for your file system in the Availability Zone where you have your EC2 instance launched.

  1. Make sure you have the following information:

    • ID of the file system (for example, fs-example) for which you are creating the mount target.

    • VPC subnet ID where you launched the EC2 instance in Step 1.

      For this walkthrough, you create the mount target in the same subnet in which you launched the EC2 instance, so you need the subnet ID (for example, subnet-example).

    • ID of the security group you created for the mount target in the preceding step.

  2. At the command prompt, run the following AWS CLI create-mount-target command.

    $ aws efs create-mount-target \ --file-system-id file-system-id \ --subnet-id subnet-id \ --security-group ID-of-the security-group-created-for-mount-target \ --region us-west-2 \ --profile adminuser

    You get the following response.

    { "MountTargetId": "fsmt-example", "NetworkInterfaceId": "eni-example", "FileSystemId": "fs-example", "PerformanceMode" : "generalPurpose", "LifeCycleState": "available", "SubnetId": "fs-subnet-example", "OwnerId": "account-id", "IpAddress": "xxx.xx.xx.xxx" }
  3. You can also use the describe-mount-targets command to get descriptions of mount targets you created on a file system.

    $ aws efs describe-mount-targets \ --file-system-id file-system-id \ --region us-west-2 \ --profile adminuser

Next Step

Step 3: Mount the Amazon EFS File System on the EC2 Instance and Test