I have an S3 bucket put event that triggers a lambda function. I need the lambda to take the file and check an EBS attached to an EC2 instance if the file exist in a directory, if it does not put it in that directory. How do I go about it? My main issue is the lambda to EBS side of things. Will be glad if some can help. Note: I do not want to use EFS because I have alot of the files on the EBS already.
Unfortunately, you are mixing 'cloud' infrastructure with 'legacy' virtual machine infrastructure and that isn't easy.
The AWS Lambda function runs outside of your EC2 instance. The Amazon EBS volume used by the EC2 instance is managed by the Operating System running on your instance, so you'd need to find a way to have the Lambda function access a 'shared disk' (which is pretty ugly).
The preferred method would be for software running on the EC2 instance to 'pull' the file(s) from S3. For example, it could run a script every hour that uses aws s3 sync
to copy files to the instance.
Or, instead of triggering an AWS Lambda function you could have S3 send a message to an Amazon SQS queue and then have some code running on the EC2 instance that will pull messages from an SQS queue and processes the file locally. This will work better than using a Lambda function because that code would have full access to the disk (since it is actually running on the EC2 instance).