🔧 Programmierung5 Useful Python Scripts to Automate CSV Processing(10.09.2026 um 14:00 Uhr)
🔧 Programmierung5 Python Techniques for Efficient Resource Orchestration(11.09.2026 um 14:00 Uhr)
🔧 ProgrammierungFrom Spaghetti Code to Clean Python: A Beginner’s Guide(11.09.2026 um 16:00 Uhr)
🔧 ProgrammierungText Watermarking in Python: Catch Whoever Copies Your Writing(06.09.2026 um 16:00 Uhr)
🔧 ProgrammierungWhy Most Multi-Agent Systems Fail Even When Evaluation Passes(07.09.2026 um 14:00 Uhr)
🔧 ProgrammierungA Beginner’s Guide to World Models(08.09.2026 um 19:27 Uhr)
🔧 Programmierung7 Async Patterns for Running Agents Concurrently in Python(11.08.2026 um 14:00 Uhr)
🔧 ProgrammierungManaging Small Context Windows in Language Models(18.08.2026 um 14:00 Uhr)
🔧 Programmierung5 Useful Python Scripts to Automate CSV Processing(10.09.2026 um 14:00 Uhr)
🔧 Programmierung5 Python Techniques for Efficient Resource Orchestration(11.09.2026 um 14:00 Uhr)
🔧 ProgrammierungFrom Spaghetti Code to Clean Python: A Beginner’s Guide(11.09.2026 um 16:00 Uhr)
🔧 ProgrammierungText Watermarking in Python: Catch Whoever Copies Your Writing(06.09.2026 um 16:00 Uhr)
🔧 ProgrammierungWhy Most Multi-Agent Systems Fail Even When Evaluation Passes(07.09.2026 um 14:00 Uhr)
🔧 ProgrammierungA Beginner’s Guide to World Models(08.09.2026 um 19:27 Uhr)
🔧 Programmierung7 Async Patterns for Running Agents Concurrently in Python(11.08.2026 um 14:00 Uhr)
🔧 ProgrammierungManaging Small Context Windows in Language Models(18.08.2026 um 14:00 Uhr)

🔧 Programmierung 🕛 vor 4 Monaten 8 Min Lesezeit
0

Cross-region data transfer from NFS server to Amazon EFS file system using AWS DataSync

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht




Overview



This AWS DataSync solution transfers data from an EC2-hosted NFS share in VPC A (us-east-1) to an Amazon EFS file system in VPC B (us-west-2). The two VPCs are connected through a peering connection. This setup simulates a typical on-premises to cloud data migration scenario.



An NFS server uses the NFS protocol to share files and directories over a network.



Amazon EFS is a fully managed, serverless cloud file storage service that provides elastic, shared file storage for Linux-based workloads and applications running on AWS services like EC2.



AWS DataSync, a fully managed, high-speed data transfer service, communicates with both storage locations via VPC endpoints, utilizing a private, fast and secure connection to accomplish the transfer.



VPC Endpoints provide private interface entry points to AWS services from within a VPC. While many AWS services have public endpoints that can be accessed over the internet, it is a best practice to use VPC endpoints to communicate with AWS services securely from within a VPC.






Architecture Diagram



 to enable  and attach an EC2 role to the NFS server for session manager to work. Attach the following AWS managed policies to the EC2 role:


  1. AmazonSSMManagedEC2InstanceDefaultPolicy

  2. AmazonSSMManagedInstanceCore








.

  • Optional name.

  • Choose “AWS services” type.

  • Type “ssm” and search.

  • Select the first option com.amazonaws.us-east-1.ssm. The name varies according to the service.

  • Next, select VPC A.


  • Check “Enable private DNS name”.

  • DNS record IP type: IPv4.


  • Subnets. Check the first two Availability Zones in the list. Under Subnet ID, select both private subnets.

  • IP address type: IPv4.

  • Security groups: Use the SSM Endpoint Security Group created earlier. You will use this security group for all VPC endpoints in region A.

  • Policy: Full access.



  • .


  • Amazon Linux AMI.


  • t2.micro instance type.

  • Proceed without a key pair.

  • PrivateSubnetA.

  • Auto-assign public IP disabled.


  • Create NFS server security group:


    1. Inbound: 


      1. HTTPS from SSM Endpoint.

      2. NFS from VPC B.

      3. ICMP from VPC B.






    2. Outbound


      1. All traffic to VPC A and B.












  • 8 GB gp3 EBS volume.




  • User data for NFS server. Creates and exports NFS share, generates files for the transfer.





  • CODE

    #!/bin/bash
    set -e
    sleep 180
    # Check if the secondary drive exists
    if ! lsblk /dev/xvdb &>/dev/null; then
    echo “/dev/xvdb not found. Exiting.”
    exit 1
    fi

    mkfs.ext4 /dev/xvdb
    mkdir -p /mnt/data
    mount /dev/xvdb /mnt/data
    echo ‘/dev/xvdb /mnt/data ext4 defaults,nofail 0 2’ | sudo tee -a /etc/fstab

    # Create and set up NFS share directory
    TARGET_DIR=”/mnt/data/nfs_share”
    PREFIX=”test”
    EXT=”.txt”
    mkdir -p $TARGET_DIR
    chown -R nobody:nobody $TARGET_DIR
    chmod 777 $TARGET_DIR

    # Function to generate files
    generate_files() {
    local start=$1
    local end=$2
    local size_range=$3
    local block_size=$4
    local group_label=$5

    local start_time=$(date +%s)
    echo “Starting generation of $group_label at $(date)

    for i in $(seq -f “%04g” $start $end); do
    FILE=${TARGET_DIR}/${PREFIX}${i}${EXT}
    SIZE=$((RANDOM % size_range + 1))
    dd if=/dev/urandom of=$FILEbs=$block_size count=$SIZE status=none &
    done
    wait

    local
    end_time=$(date +%s)
    echo “Finished generation of $group_label at $(date)
    local elapsed_time=$((end_time - start_time))
    echo “Time taken for $group_label: ${elapsed_time} seconds”
    }

    # Generate file groups with time tracking
    generate_files 1 1000 100 1K “1000 files (1KB to 100KB)” &
    generate_files 1001 1100 100 1M “100 files (1MB to 100MB)” &

    wait
    echo
    “File generation complete in $TARGET_DIR

    sed -i\|^$TARGET_DIR |d” /etc/exports
    echo$TARGET_DIR *(rw,sync,no_root_squash,no_all_squash)” | sudo tee -a /etc/exports > /dev/null
    systemctl start nfs-server
    systemctl enable nfs-server
    exportfs -rav






    Verify that you can connect to the NFS server via Session Manager.






    US-WEST-2






    VPC B




    1. Create a target VPC in us-west-2 with 172.31.0.0/16 Cidr.

    2. Create two public subnets and an internet gateway.

    3. Create two private subnets and a NAT gateway.

    4. Follow the same steps as in Region A to enable Session Manager to access the NFS client.


    5. Create and attach an SSM Endpoint Security Group to all the endpoints:




      1. Inbound: 


        1. HTTPS from DataSync agent.

        2. NFS from VPC B.

        3. 1024 – 1064 from DataSync agent.






      2. Outbound


        1. All traffic to VPC B.










    6. Attach the same EC2 role created from VPC A to the NFS client if you are in the same account. For different accounts, you need to create a new EC2 role for the NFS client.





    7. .



    8. t3.micro instance type.

    9. Proceed without a key pair.

    10. PrivateSubnetA.

    11. Auto-assign public IP disabled.

    12. Create a DataSync agent security group as follows:


      1. Inbound: 


        1. HTTPS from VPC B.

        2. HTTP from NFS client.

        3. ICMP from NFS client.






      2. Outbound


        1. All traffic to VPC A and B.












    13. 20 GB gp3 EBS volume.







    VPC B Endpoints



    Follow similar procedures from US-EAST-1 to create VPC endpoints for:




    1. SSM.

    2. EC2-Messages.

    3. SSM-Messages.

    4. EFS.

    5. DataSync.



    .


  • Amazon Linux AMI.


  • t2.micro instance type.

  • Proceed without a key pair.


  • PrivateSubnetA.

  • Create an NFS client security group:


    1. Inbound: 


      1. HTTPS from VPC B.






    2. Outbound


      1. All traffic to VPC A and B.












  • 8 GB gp3 EBS volume.







  • EFS file system




    1. Create an EFS Security Group with the following rules:


      1. Inbound: 


        1. NFS traffic from VPC B.

        2. NFS traffic from NFS Client.

        3. NFS traffic from DataSync agent. 

        4. NFS traffic from SSM Endpoint.

        5. HTTPS from VPC B and SSM Endpoint.

        6. ICMP from NFS client.






      2. Outbound


        1. All traffic to VPC B.












    2. .

    3. Optional name.

    4. VPC ID (Requester): VPC A ID.

    5. Select another VPC to peer with: My account.

    6. Region: Another Region.

    7. VPC ID (Accepter): VPC B ID.



    , select the peering connection available.

  • From the “Actions” menu, Accept request. Confirm.






    1. Update the private route table for VPC B to forward Region A traffic to the peering connection.










    DataSync agent



    Obtain the activation code of the DataSync agent from the NFS client.




    CODE
    # Test connectivity to the agent
    nc -vz 172.31.x.x 80

    # Obtain activation code
    sudo curl “http://<datasync-agent-ip>/?gatewayType=SYNC&activationRegion=us-west-2&privateLinkEndpoint=<datasync-vpce-ip>&endpointType=PRIVATE_LINK&no_redirect”

    # NB: Replace <datasync-agent-ip> and <datasync-vpce-ip> with actual values







    Activate the DataSync agent using the activation key.




    CODE
    aws datasync create-agent \
    --agent-name “datasync-agent” \
    --activation-key “xxxxx-xxxxx-xxxxx-xxxxx-xxxxx” \
    --vpc-endpoint-id “vpce-xxxxxxxxxxxxxxxxx” \
    --subnet-arns “arn:aws:ec2:us-west-2:accountId:subnet/subnet-xxxxxxxxxxx” \
    --security-group-arns “arn:aws:ec2:us-west-2:accountId:security-group/sg-xxxxxxxxxxxx”







    Create the NFS location.




    CODE
    aws datasync create-location-nfs \
    --server-hostname “10.0.x.x” \
    --subdirectory “/mnt/data/nfs_share” \
    --on-prem-config AgentArns=”arn:aws:datasync:us-west-2:accountId:agent/agent-xxxxxxxxxxx”







    Create the EFS location.




    CODE
    aws datasync create-location-efs \
    --efs-filesystem-arn “arn:aws:elasticfilesystem:us-west-2:accountId:file-system/fs-xxxxxxxxxxxxx” \
    --ec2-config SubnetArn=”arn:aws:ec2:us-west-2:accountId:subnet/subnet-xxxxxxxxxxxxx”,SecurityGroupArns=”arn:aws:ec2:us-west-2:accountId:security-group/sg-xxxxxxxxxxxxxxx”







    Create a task that connects both locations and start the task.




    CODE
    aws datasync create-task \
    --source-location-arn “arn:aws:datasync:us-west-2:accountId:location/loc-xxxxxxxxxxxxxx” \
    --destination-location-arn “arn:aws:datasync:us-west-2:accountId:location/loc-xxxxxxxxxxxxxx”






    .


  • .


  • .

  • Vollständiger Original-Bericht
    Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
    ↗ Original-Artikel auf dev.to lesen
    Wie bewertest du diesen Beitrag?
    1 Klick Feedback
    Teilen mit Netzwerk & Team:

    Community-Analysen & Experten-Meinungen 0

    Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
    Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
    Community Pulse: Relevanz-Einschätzung
    1 Klick Experten-Votum
    🔴 Akute Relevanz 0%
    🟡 In Evaluierung 0%
    🟢 Keine Auswirkung 0%
    Spannende Innovation 0%
    Verwandte Story-Cluster & Quellen (Vektor-KI)
    Port 8095 Engine
    1 Quelle
    5 Useful Python Scripts to Automate CSV Processing
    1 Quelle
    5 Python Techniques for Efficient Resource Orchestration
    1 Quelle
    From Spaghetti Code to Clean Python: A Beginner’s Guide
    Ähnliche Beiträge
    🔍 Verwandte News

    Auch interessante Nachrichten Cross-region data transfer from NFS server to Amazon EFS file system using AWS DataSync

    Thematisch verwandte Begriffe: Crossregion, data, transfer, from · 6 Treffer

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...