1

Just to give you a context... I'm new to the aws world and all the services that provides.

I have a legacy application which I need to share some binarys with a client, and I was trying to use a ec2 instance (Amazon Linux AMI) with samba, to map it into a windows local machine. I was able to establish a conection with another ec2 instances (same vpc), just as a tryout. But I wasn't able to do so with my windows machine or even with a linux vm I have. The inbound rules for this concept ec2 instance was fully open (All traffic allowed).

Main question

Is it possible to do? Share a file system between a ec2-instances with a (over internet) local machine?


Just saying: S3 storage isn't an option. And in my region FSX still ain't implemented and for latency reasons is a no go.

Please ask as many questions you want, I'll try to anwser them as fast as I Can. Kind Regads.

  • Yes, both Linux and Windows support exporting file shares. Google search Samba (Linux) or CIFS (Window). I am listing both for future readers. However, unless you are careful, you could expose your system to the Internet. A better option is to use an SSH GUI based program that provides file access (SFTP) to the remote system in the cloud. I use BitVise which works very well. – John Hanley Mar 25 '20 at 21:16
  • Thank you for the answer, but my question was a more focus aws issue based. I do know (mostly) how samba work, I do have a couple of raspberrys lying somewhere in my flat and use samba to share files and stuff. Again, thank you – agustinlare Mar 26 '20 at 13:31
  • This is not an AWS issue as AWS offers nothing to serve files from inside your instance. This is an operating system and firewall/security issue. – John Hanley Mar 26 '20 at 17:11

1 Answers1

0

TL;DR - it's possible, but there's no 'simple' solution (in my opinion).

I thought of two possible solutions that you can implement, here we go ...

1: AWS EFS, AWS Direct Connect and Docker

A possible solution would be using AWS Elastic File System (EFS), AWS Direct Connect and a Docker Linux container.

Drawbacks

  1. If it's the first time you encounter with the above AWS services or Docker, then it's going to be a bit of a journey to learn about them
  2. EFS pricing - it's not so cheap, and you also need to consider the inbound and outbound traffic, it's best to use the calculator that is in the pricing page
  3. EFS performance - if you only share files then it should be okay, but if you expect to get high speeds, then remember that it's not an EBS volume, so for higher speeds you need to pay more money
  4. AWS Direct Connect pricing - you also need to take that into consideration
  5. Security - I'm not sure how sensitive your data is, but you need to make sure you create a very strict VPC, with Security Groups and Network Access List rules - read about the VPC Security Best Practices

Steps to implement the solution

Follow the Walkthrough: Create and Mount a File System On-Premises with AWS Direct Connect and VPN, also, here are the steps on how to combine it with Docker

  1. (Optional) To make it a bit easier - for Windows to "support" Linux file-system, you should use Windows Git Bash. If you're not sure how to use install 3rd-party apps in Windows Git Bash (like aws-vault) then read this blog post
  2. Create an EFS in AWS, and mount it to your EC2 instance, read more about it here
  3. Use AWS Direct Connect to connect to your VPC from your local Windows machine
  4. Install Docker for Windows on your local machine
  5. Create a Docker Volume, and mount the same EFS to that volume - a good example for this step
  6. Test it - SSH to your EC2 instance, create a file on the EFS volume and then check in your local Docker Linux container that this file appears on the EFS volume

I omitted the security steps because it's up to you how strict you want your solution to be.

2: Using S3 as a shared file-system

You can try out this tool s3fs-fuse, but you'll still need to use a Docker Linux container since you're on Windows. I haven't tested it but it looks promising. You can read this blog post, it's a step-by-step tutorial on how to do it, and also shares some other possible solutions.

Meir Gabay
  • 2,870
  • 1
  • 24
  • 34
  • thanks you so much, i'll definitely try it in fully. I did a proof concept, all localy with docker on my windows machine (since the clientes pc have windows) and wasn't able to make it work both ways... as soon as I mount the samba share the volume in my windows stops makeing any update. – agustinlare Mar 27 '20 at 02:29
  • So you've already tested both of the suggested solutions and both didn't work? If that is the case, may you please share why it didn't work? What error did you get? – Meir Gabay Mar 27 '20 at 10:55
  • Sorry for the delay. Actualy what I test was a proof of concept. First stage: I setup a 2 containers, one as a samba server, and another as a samba client, test them, work fine. Second: to the samba server container I persist the volume (-v flag) to a path on my windows computer, both containers work perfectly. Final stage: I persist the volume where the samba client was sharing with the samba client, and even though between containers work fine, the volume in windows stop updateing the changes made in the samba server – agustinlare Mar 30 '20 at 14:38
  • I'm not sure I understand what do you mean by "I persist the volume" - are you using bind mound, are you creating a volume or are you using bind mount? https://docs.docker.com/storage/bind-mounts/#start-a-container-with-a-bind-mount , it sounds like you need to use bind mount, and not the `-v` flag, are you familiar with it? – Meir Gabay Mar 31 '20 at 06:20
  • Sorry about the persist volume, kubernetes f*@%me up. Actualy didn't know you can use --mount without swarm. I try it did't work neither, `--mount type=bind,source=D:\dockerdrive\samba-cliente,target=/tmp/shared`, as soon I mount it the host fs stops updateing, with samba server works fine tho. – agustinlare Apr 01 '20 at 14:43
  • I think I lost you ... Not sure how to help .. I hope you'll be able to figure it out – Meir Gabay Apr 01 '20 at 15:10