Currently in the environment I am building out, a file gets submitted to an S3 bucket from a web form as a JSON file. When that file arrives in the S3 bucket, it triggers AWS Lambda to turn on an EC2 instance. That EC2 needs to download that file in the S3 bucket and feed it into an application. Once it is done, a file gets submitted to an S3 bucket and triggers AWS Lambda, which turns off the EC2 instance.
What is the best way to download that file? These are some ideas I had, but I am unsure if they are possible/practical:
- Pass the S3 object ID of the file which triggered AWS Lambda to EC2 (With Lambda)
- Pass the S3 object ID of the most recently uploaded file in an S3 bucket to EC2
- Get the S3 object ID of the only file in a bucket (Ex: mybucket/uploaded_files/) using AWS CLI
Once the EC2 instance is passed the object ID, it will download it. Thoughts/opinions? Thanks.
Edit for clarification: The file getting uploaded to the S3 bucket is a JSON file containing configuration options for the application. There will only ever be a single EC2 instance (because this is a side project).