0

I am trying to use java sdk to create a local filesystem on an EC2 machine which would actually be a S3 resource

I have already written code to start EC2 machine, create security groups, keys etc but now want to mount a S3 on top of that EC2 machine that I create using java SDK. There seems to be no detailed solution online.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Scooby
  • 3,371
  • 8
  • 44
  • 84

2 Answers2

0

While there is a file system provider s3fs build on fuse. Is not always a good idea to try to mount it to the file system. Instead you should either use command line tools s3cmd or build in access to s3 into your filesystem.

The reason why I would recommend against it is that s3 is not a block device while the rest of your file system is. Everything on s3 is treated as a complete object. You can't read or write to a block of the object.

If all your are doing with the mount is copying files in its entirety to and from s3, a file system mount may work reasonably well. But you can't run anything that would expect block level acccess to files on that mount.

datasage
  • 19,153
  • 2
  • 48
  • 54
0

First, you should prepare your own AMI with s3fs pre-installed. See https://forums.aws.amazon.com/thread.jspa?threadID=39361. The EC2 instance should be started from this custom AMI.

Second, right after the instance is up and running, you should establish an SSH connection to it and run

/usr/bin/s3fs bucketname /mnt/mountpoint

I would recommend to use JSch

yegor256
  • 102,010
  • 123
  • 446
  • 597