Home > OS >  Amplify s3 trigger for storage
Amplify s3 trigger for storage

Time:01-21

i have crated an amplify react app with a storage where i can save my pdf file, i have create a trigger from the aws interface, but when i load a file my app don't trigger the lambda function. i load all file in a public folder of my storage and if i go in my storage properties i have the event event. when i try the function manualy i have the event in cloudwatch but when i insert a document in my s3 bucket no. where is the problem? Where am I doing wrong? this is my trigger trigger and this is my function lambda code thanks for help

i try to retrive pdf file when is load in a s3 bucket

CodePudding user response:

You created the trigger "from the aws interface". I don't believe "Amplify Studio" supports that yet, and you should never make changes to Amplify generated resources via the "AWS Console" web interface.

You should probably undo whatever you setup, and then do an amplify push from within your project to make sure it still deploys.

If your S3 bucket (Storage) is managed by Amplify, and your Lambda (Function) is managed by Amplify, then you can easily generate a trigger that will activate the Lambda when changes occur in the S3 bucket.

From Amplify trigger documentation, you add the trigger from the S3 bucket:

amplify update storage

Then

? Do you want to add a Lambda Trigger for your S3 Bucket? Yes
? Select from the following options
❯ Choose an existing function from the project
  Create a new function

After those steps, deploy your changes:

amplify push

Then go ahead and drop a test file into your S3 bucket.

Your lambda will receive all S3 events for the bucket. Your code probably only wants to process the s3:ObjectCreated events.

  • Related