How to invoke s3 create object event using sam-local
I have written a Lambda function that uploads data from a file to Database when a new file is uploaded to S3. I have the test file on my local folder. How do i generate an S3 event which mimics file upload on s3 bucket by pointing to my local folder? For example, i have "test.txt" file sitting in /usr/local/samlocal-files/ folder on my local. So, how do i create S3 event in a way that S3Object object = amazonS3.getObject(new GetObjectRequest(s3Bucket, s3Key)); is able to read file "/usr/local/samlocal-files/test.txt" ?
+1
+1
I can't tell from the docs if:
- this is not possible and we never said it was
- we can simulate a local s3 in this way
- we can proxy an actual s3 in this way
That would be very helpful
I have the same function and use minio to simulate the S3 locally
@danilopopeye Would you please mind providing us an example project with your workaround?
@jkomyno have a look in this doc aws-sdk-for-javascript-with-minio. This is basically what I did.
sam local generate-event s3 is what you need. Give it a try
Created event file sam local generate-event s3 >>event.json using SAM 0.3.0
sam local invoke -e event.json
Resulting timeout error at s3.getObject(params, (err, data) => {
Error 2018-06-21 16:44:00 Function 's3getobject' timed out after 15 seconds What could be the issue?
sam local generate-event s3is what you need. Give it a try
This will generate an S3 object event. What we need is the ability to seed data into the "local S3 bucket resource" so it can be retrieved from the Lambda which is triggered by the event.
This will generate an S3 object event. What we need is the ability to seed data into the "local S3 bucket resource" so it can be retrieved from the Lambda which is triggered by the event.
I was wondering if it is possible to simulate a S3 resource PUT and lambda-function fetching S3-object on trigger with sam local ?? Please let me know how can I do that ?
This will generate an S3 object event. What we need is the ability to seed data into the "local S3 bucket resource" so it can be retrieved from the Lambda which is triggered by the event.
I was wondering if it is possible to simulate a S3 resource PUT and lambda-function fetching S3-object on trigger with
sam local?? Please let me know how can I do that ?
@avimehenwal I was looking for the same, Have you find any?
here is what worked for me :
get options for each service:
sam local generate-event s3
generate appropriate payload:
sam local generate-event s3 put >> event.json
run InsertFunctionName with the event
sam local invoke InsertFunctionName -e event.json