Menu
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.

  • 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

  1. Create a file system and add the optional Name tag.

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

      Copy
      $ aws efs create-file-system \ --creation-token FileSystemForWalkthrough1 \ --region us-west-2 \ --profile adminuser
    2. Verify the file system creation by calling the describe-file-systems CLI command.

      Copy
      $ aws efs describe-file-systems \ --region us-west-2 \ --profile adminuser

      Here's an example response:

      Copy
      { "FileSystems": [ { "SizeInBytes": { "Timestamp": 1418062014.0, "Value": 1024 }, "CreationToken": "FileSystemForWalkthrough1", "CreationTime": 1418062014.0, "FileSystemId": "fs-cda54064", "PerformanceMode" : "generalPurpose", "NumberOfMountTargets": 0, "LifeCycleState": "available", "OwnerId": "account-id" } ] }
    3. Note the FileSystemId value. You need this value when you create a mount target for this file system in the next step.

  2. (Optional) Add a tag to the file system you created using the create-tag CLI command.

    You don't need to create a tag for your file system to complete this walkthrough. But you are exploring the Amazon EFS API, so let's test the Amazon EFS API for creating and managing tags. For more information, see CreateTags.

    1. Add a tag.

      Copy
      $ aws efs create-tags \ --file-system-id File-System-ID \ --tags Key=Name,Value=SomeExampleNameValue \ --region us-west-2 \ --profile adminuser
    2. Retrieve a list of tags added to the file system by using the describe-tags CLI command.

      Copy
      $ aws efs describe-tags \ --file-system-id File-System-ID \ --region us-west-2 \ --profile adminuser

      Amazon EFS returns tags list in the response body.

      Copy
      { "Tags": [ { "Value": "SomeExampleNameValue", "Key": "Name" } ] }

Step 2.2: 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.

    Copy
    $ 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 this response:

    Copy
    { "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.

    Copy
    $ 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