DEV Community

Discussion on: Sending emails only once with AWS Step Functions

Collapse
 
wojciechmatuszewski profile image
Wojciech Matuszewski • Edited

Thank you for sharing.

One question: Why did you not leverage the name attribute on the StepFunction execution to enforce uniqueness?

According to the StepFunctions API documentation the name has to be unique (90 days grace period). Maybe you could use that instead of saving the hash into the DB?

Collapse
 
danielfy profile image
Daniel Fyhr

Thank you for your feedback.

I think your solution with using the name is a good way to solve it. In that case maybe you can use an outer state machine to create the hash and then start the inner machine (using the hash as name).

Some things that come to mind as advantages with using DynamoDB are if you want more control over the grace period by using time to live in DynamoDB. Another use case is if you want to keep track of what you have sent without relying on the email delivery provider. In that case you could use something like

{
  PK: `EMAIL#${email.to}`,
  SK: `HASH#${hash}`,
  // additional fields
}
Enter fullscreen mode Exit fullscreen mode

To be able to query on receiving email address.

Do you have any other aspects to consider?