question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to allow s3 notification events to save picture to dynamodb

See original GitHub issue

i’ve declared a s3Stack with a notification function that will invoke upon item picture is uploaded to s3 bucket. however, in the notification function, i am trying to save some of the image metadata (url, filename etc) to a dynamoDB.

export async function savePhotoToDB(item) {
  console.log(`ASSET TABLE NAME: ${process.env.ASSET_TABLE_NAME}`);
  const params = {
    // Get the table name from the environment variable
    TableName: process.env.ASSET_TABLE_NAME,
    Item: item,
  };
  await dynamoDb.put(params).promise();
}

process.env.ASSET_TABLE_NAME always return undefined. how should i define it in my s3Stack so that i can access it in the above function which will trigger upon file uploaded to s3 bucket?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
fxyongcommented, Jun 22, 2021

thanks @fwang ! that did the trick!

0reactions
fwangcommented, Jun 22, 2021

Try this:

...

      notifications: [
        {
          function: {
            handler: "src/note-service/processAsset.main",
            environment: {
              ASSET_TABLE_NAME: assetTable.dynamodbTable.tableName,
            },
          },
          notificationProps: {
            events: [s3.EventType.OBJECT_CREATED],
          },
        },
      ],

...
Read more comments on GitHub >

github_iconTop Results From Across the Web

enable and configure event notifications for an S3 bucket
In the Buckets list, choose the name of the bucket that you want to enable events for. Choose Properties. Navigate to the Event...
Read more >
Configuring AWS S3 Event Notifications | Notify SNS Topics ...
DevOps Online Training Registration form: https://bit.ly/valaxy-formFor Online training, connect us on WhatsApp at +91-9642858583 =======...
Read more >
How to import CSV data into DynamoDB using Lambda and ...
On the S3 Console / Click on the s3 bucket named friends-s3 · Click on the Properties tab / go down to Event...
Read more >
Amazon Web Services - Amazon S3 Notifications to SNS
Create Event Configuration: To create events, go to the properties of the bucket and click on create event notifications tab. Specify the event...
Read more >
AWS S3 Bucket: Event Notifications | by Priyam Chauhan
Enabling S3 Event Notifications · Login to AWS Console and head to S3 service. · Select the S3 bucket on which you want...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found