Thursday 19 September 2024

EFS AWS labs step by step

Step 1: Set Up Your AWS Account

  1. Sign In: Log into your AWS Management Console.
  2. IAM User: Ensure you have an IAM user with appropriate permissions (AmazonElasticFileSystemFullAccess).

Step 2: Create an EFS File System

  1. Navigate to EFS:

    • In the AWS Management Console, search for “EFS” and select Elastic File System.
  2. Create File System:

    • Click on Create file system.
    • Select your VPC and availability zones.
    • Choose the performance mode (General Purpose or Max I/O) based on your use case.
    • Configure throughput mode (Bursting or Provisioned).
    • (Optional) Enable encryption at rest and in transit.
    • Click Create file system.

Step 3: Configure EFS Mount Targets

  1. Mount Targets:
    • After creating the file system, click on it to view details.
    • Click on Network and then Add mount targets.
    • Select subnets (in different availability zones for redundancy).
    • Specify security groups to control access.
    • Click Add mount targets.

Step 4: Create an EC2 Instance to Access EFS

  1. Launch EC2 Instance:
    • Navigate to EC2 in the AWS Management Console.
    • Click on Launch Instance.
    • Choose an Amazon Machine Image (AMI), such as Amazon Linux 2.
    • Select an instance type (e.g., t2.micro for testing).
    • Configure network settings to ensure the instance is in the same VPC as the EFS.
    • (Optional) Create or select an existing security group allowing NFS access (port 2049).
    • Click Launch.

Step 5: Install NFS Client on EC2

  1. Connect to EC2 Instance:

    • Use SSH to connect to your EC2 instance.
  2. Install NFS Utilities:

    bash

    sudo yum install -y nfs-utils # For Amazon Linux

Step 6: Mount the EFS File System

  1. Create a Mount Point:

    bash

    sudo mkdir /mnt/efs
  2. Mount EFS:

    • Use the EFS DNS name to mount:
    bash

    sudo mount -t nfs4 <EFS-DNS-NAME>:/ /mnt/efs
    • Replace <EFS-DNS-NAME> with the actual DNS name from your EFS console.
  3. Verify Mount:

    bash

    df -h

Step 7: Test EFS

  1. Create a Test File:

    bash

    echo "Hello EFS" | sudo tee /mnt/efs/testfile.txt
  2. Verify File:

    bash

    cat /mnt/efs/testfile.txt

Step 8: Configure Automatic Mounting (Optional)

  1. Edit fstab:

    • Open the fstab file:
    bash

    sudo nano /etc/fstab
  2. Add EFS Entry:

    • Add the following line at the end of the file:
    javascript

    <EFS-DNS-NAME>:/ /mnt/efs nfs4 defaults,_netdev 0 0
  3. Test fstab:

    bash

    sudo umount /mnt/efs sudo mount -a

Step 9: Clean Up

  1. Unmount EFS:


    sudo umount /mnt/efs
  2. Delete EC2 Instance:

    • Navigate to the EC2 console and terminate the instance.
  3. Delete EFS File System:

    • Go back to the EFS console and delete the file system.

No comments:

Post a Comment