Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(filemanager): move SQS and DLQ to stateful stack #101

Merged
merged 10 commits into from
Feb 15, 2024

Conversation

mmalenic
Copy link
Member

@mmalenic mmalenic commented Feb 9, 2024

Closes #86

I think this one I'll merge before #98, so that #98 can implement the createFilemanager() function inside the stateless stack.

Note that the architecture is slightly different to the diagram. The Lambda function depends on an IQueue construct directly, rather than an SQS url, and has the option to send events to the DLQ. So the final diagram could look more like this, where the DLQ receives events from both the SQS queue and the filemanager Lambda function: The diagram is now like the original design.

Changes

@mmalenic mmalenic self-assigned this Feb 9, 2024
@mmalenic mmalenic added the filemanager an issue relating to the filemanager label Feb 9, 2024
@mmalenic mmalenic added the feature New feature label Feb 9, 2024
@@ -98,6 +97,9 @@ export const getEnvironmentConfig = (
securityGroupProps: {
...orcaBusStatefulConfig.securityGroupProps,
},
eventSourceProps: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC the event sources will eventually have to be dynamic? As in not requiring a de-deploy when we want to monitor and ingest new buckets... I guess that's a future feature, but just keeping tabs open on the topic as I guess that this will eventually have to go to some Rust AWS SDK lambda instead of CDK? ... thinking out loud, no need to address this in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, could potentially have env variables that contain an SQS url that the Lambda function uses. Although, wouldn't every new bucket need to somehow be registered with the SQS queue, requiring CDK? Not sure how SQS could discover these on its own, unless there's just a blanket "all buckets" EventBridge rule.

Copy link
Member

@brainstorm brainstorm Feb 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. @reisingerf, what were your thoughts from previous meetings on this? I'm not sure what are the requirements for this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that buckets of interest are configured to send events to the EventBus, to make those discoverable.

Marko's statefull stack will contain (and be expanded with) Event Rules that then funnel events from those buckets of interest to the SQS queue.
The stateless FM stack does not need to change at all for this, as it simply consumes events from the SQS.

Does that make sense?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so the dev story of adding a new "bucket of interest" is declaring it statically in CDK (on the EventBus construct/stack in this case) or those Event Rules will be lax enough to just process events from a new bucket? Or some other mechanism I'm not understanding? :-S

Copy link
Member

@reisingerf reisingerf Feb 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"adding a new bucket" is simply adding a new Rule to the stateful stack to forward the events to SQS. This should always be possible, even if there is no such bucket (as it's a simple pattern matching on the EventBus side).

How actual events get to the EventBus is a different story and outside the scope of the stack. This would be the responsibility of whoever controls the bucket in question.

Copy link
Member Author

@mmalenic mmalenic Feb 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, could be nice to have the ability to add multiple EventBridge rules to the same SQS queue within this PR. Not sure if this is super useful though because multiple buckets can already be defined for the same rule.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, about that...
I need to brush up on the Rule syntax, but if I understand the code correctly then the rule filters for a known list of buckets and a given prefix, right?

That prefix would have to be the same across all the listed buckets though?
If yes, then I think I'd prefer a rule per bucket / concern... easier to keep track of and maintain independence.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's one prefix for all the buckets. I think you're right, it might make more sense to have it defined per bucket.

bin/orcabus.ts Outdated Show resolved Hide resolved
/**
* The dead letter queue ARN.
*/
deadLetterQueueArn: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you want to pass on the DLQ?

…e this is automatically handled by SQS retries
…-sqs

# Conflicts:
#	config/constants.ts
#	lib/pipeline/orcabus-stateful-pipeline-stack.ts
#	test/stateful/eventSourceConstruct.test.ts
@mmalenic
Copy link
Member Author

Updates

  • Queue name is passed in static config so that the stateless and stateful pipeline can be separate.
  • EventBridges rules are configurable per bucket instead of for all buckets.
  • Dead letter queue is only applied to the SQS queue within the EventSource construct.

});

test('Test EventSource created props', () => {
new EventSource(stack, 'TestDatabaseConstruct', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess TestDatabaseConstruct should be updated to TestEventSourceConstruct...
(also for the following tests)

Copy link
Member

@reisingerf reisingerf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mmalenic mmalenic merged commit a3e74d9 into main Feb 15, 2024
2 checks passed
@mmalenic mmalenic deleted the feat/filemanager-sqs branch February 15, 2024 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature filemanager an issue relating to the filemanager
Projects
No open projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

filemanager: link bucket EventBridge rules to an SQS queue
3 participants