Reputation: 182
The short question: How do I sync one folder in my PHP application on AWS Elastic Beanstalk with an S3 bucket automatically? With Lambda for example, or if there is any other AWS function that I can use.
The long story I have deployed a PHP application on Elastic Beanstalk, my repo is on GitHub, and I use AWS CodePipeline to track the changes. When I update the repo, the new version gets deployed to Elastic Beanstalk. The problem is, I have one folder called (/images) where I save my users' photos. This folder gets deleted with every new deployment.
My workaround today is -> Login to the EC2 machine that is serving the app -> aws s3 sync /var/app/current/images/ s3://bucketname
I want to automate the process and make it more robust.
Upvotes: 1
Views: 876
Reputation: 648
You could use s3fs-fuse to mount an s3 bucket as a folder on your drive and use it as a normal file system for all practical purposes.
S3FS-Fuse: https://github.com/s3fs-fuse/s3fs-fuse
You might also alternatively consider something like EFS (Elastic File Storage) which you can use as a network mounted drive from multiple machines which would not break even when you scale up.
Upvotes: 2