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.