QThompson
QThompson

Reputation: 1708

How to send database report as csv sheet to an email?

I am needing to export some data from DynamoDB or Postgres as a csv and send that file to an email every month. Is there a scheduler I can set up that will do this for me? Or will I need to create a lambda function to export data and send the email every month?

Upvotes: 1

Views: 1333

Answers (1)

Nick Walsh
Nick Walsh

Reputation: 1875

To automate this as much as possible, your best bet is writing a lambda.

You can setup a recurring monthly event trigger using CloudWatch Events that will remove the need to manually kick things off.

Inside the lambda, your code would query the data from DynamoDB or Postgres, generate the CSV, and send it directly to the target over email as an attachment using Amazon SES (Simple Email Service). You could also choose to store the CSV in S3 before sending it over email, to have as a backup in case email delivery doesn't work as expected (for one reason or another).

  1. Tutorial: Schedule AWS Lambda Functions Using CloudWatch Events
  2. Using File Attachments with Amazon SES

Upvotes: 1

Related Questions