# Replaying events using AWS S3

DevFeed: [Replaying events using AWS S3](<https://devfeed.tech/articles/replaying-events-using-aws-s3-23901.md>)

Original publisher: [Read original article](<https://medium.com/smg-real-estate/replaying-events-using-aws-s3-3cc84242025e?source=rss----2186e5b9bd8f---4>)

Author: Marko Savic

Published: 2022-04-08T08:40:24Z

Content type: tutorial

Language: en

Sources: [Homegate Engineering Blog - Medium](<https://devfeed.tech/sources/homegate-engineering-blog-medium.md>)

Topics: [Amazon S3](<https://devfeed.tech/topics/amazon-s3.md>), [event driven](<https://devfeed.tech/topics/event-driven.md>), [Microservices](<https://devfeed.tech/topics/microservices.md>), [Amazon Web Services](<https://devfeed.tech/topics/aws.md>), [AWS CloudFormation](<https://devfeed.tech/topics/aws-cloudformation.md>), [Serverless](<https://devfeed.tech/topics/serverless.md>)

Tags: [aws](<https://devfeed.tech/tags/aws.md>), [aws-lambda](<https://devfeed.tech/tags/aws-lambda.md>), [aws-s3](<https://devfeed.tech/tags/aws-s3.md>), [cloudformation](<https://devfeed.tech/tags/cloudformation.md>), [debugging](<https://devfeed.tech/tags/debugging.md>), [event-driven](<https://devfeed.tech/tags/event-driven.md>), [event-sourcing](<https://devfeed.tech/tags/event-sourcing.md>), [lambda](<https://devfeed.tech/tags/lambda.md>), [microservices](<https://devfeed.tech/tags/microservices.md>), [s3](<https://devfeed.tech/tags/s3.md>), [serverless](<https://devfeed.tech/tags/serverless.md>), [sns](<https://devfeed.tech/tags/sns.md>), [software-architecture](<https://devfeed.tech/tags/software-architecture.md>), [versioning](<https://devfeed.tech/tags/versioning.md>)

## AI overview

This tutorial describes replaying failed events in serverless, event-driven microservices by storing AWS Step Functions events in versioned Amazon S3 objects. It also outlines using a dead-letter queue and Lambda to retrieve the latest event and trigger the workflow again.

## Source excerpt

In the world of event-driven microservices one of the important tasks is to have a mechanism to recover from failed events, as well as to have possibility to replay certain events. We at Homegate deal with serverless microservices. If, at any of these services, we encounter a failure during processing of an resource, we might need to recreate the last event or series of events for given resource. Usecase The central part of ingestion process is AWS StepFunctions that lives in a, so called, importer service. It is responsible for various enrichments and conditional actions on resource. The last step of the step function is sending an event to the AWS SNS which is consumed by many downstream services as you can see in the following diagram. Step functions as central part of ingestion process Here, many open questions can be identified: How to deal with failure within AWS StepFunctions? How to recreate SNS event if needed for downstream system? Would it be possible to replay the whole step function? Solution Possible answer to these questions would be to store events that goes through AWS StepFunctions into some kind of event storage, in Homegate case, we chose AWS S3. In order to support the whole history of events for given resource, S3 bucket versioning is used. This is quite handy for replaying series of events or even for debugging purposes. Here is a sample CloudFormation which enables that functionality: EventLogBucket: Type: 'AWS::S3::Bucket' Properties: BucketName: 'sample-unnique-bucket-name' AccessControl: Private PublicAccessBlockConfiguration: BlockPublicAcls: true BlockPublicPolicy: true IgnorePublicAcls: true RestrictPublicBuckets: true Tags: - Key: service Value: sample-service - Key: env Value: !FindInMap [ Stages, !Ref Stage , Env ] VersioningConfiguration: Status: Enabled That way we can replay the whole step functions flow using last logged event for given resource. That functionality could be available from different places, like DLQ or via api end