sst / ion

❍ — a new engine for SST
https://ion.sst.dev
MIT License
1.09k stars 129 forks source link

Add SES monitoring support to Email resource #402

Open colemahatmccreary opened 1 month ago

colemahatmccreary commented 1 month ago

as first mentioned in this discord exchange with Frank, it would be great if the email resource supported monitoring SES events via an SNS topic, as described in the AWS docs.

batteries-included config for automatically setting up the topic along with any lambda/queue/email/other subscribers would be major.

happy to keep bouncing ideas (and it sounded like @san4d had more specifics in mind), but my idea for the API would be something along these lines:

new sst.aws.Email('MyEmail', {
   sender: 'sender@foo.bar',
   monitoring: {
      email: [
         'email_admin@bar.org'
         'another_email_admin@bar.org'
      ],
      lambda: [
         new sst.aws.Function('EmailTopicLambdaSubscriber', {...})
      ],
      queue: [...],
      sms: [...],
      ...
   }
})

it'd probably make sense for each subscriber to specify which events it receives, with something like:

...
monitoring: {
   email: [
      {
         events: [...],
         recipient: 'email_monitor@bar.org'
      }
   ],
   lambda: [
      {
         events: [...],
         resource: new sst.aws.Function('EmailTopicLambdaSubscriber1', {...})
      },
      {
         events: [...],
         resource: new sst.aws.Function('EmailTopicLambdaSubscriber2', {...})
      }
   ]
}
   ...