-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add File source with SQS notifications (#5148)
* Refactor file source * More explicit reponse for read_batch * Fix clippy * Remove batch logic from DocFileReader * Address styling comments * Replace FileSourceParams path with URI * Additional URI related cleanup * Fix unit tests to now use the URI * Add queue source with SQS implementation * Fix the publish_token strategy * Fix never-used warnings * Fix unit tests * Abort visibility task after acknowledging * Address smaller review comments * Shorten visibility extension task * Fix pulsar tests * Adjustments after rebase * Move object backed source to file source * Simpler flow for adhoc file processing * Fix tests and refactor batch creation to BatchReader * Add max_messages param to Queue.receive * Move use_shard_api to the metastore crate * Dedup within batches * Improve visibility task * Re-acquire partitions aggressively * Address simpler review comments * Add test for visibility actor (failing) * Fix visibility actor drop * Fix reader edge case * Add end to end tests * Improve integration test scenario * Chunk receive future to avoid hanging actor * Improve error handling * Fix flaky test * New SourceConfig format with notifications field * Improvements to error handling * Clarification of Queue contract * Address new round of review comments * Remove SqsSource for now * Fix panic * Revert to forbidding any adhoc file source through the API * Add docs * Fix panic on empty file * Documentation improvments * Improve documentation * Improve error handling code and associated docs * Nitpic and TODO cleanup * Add tip about ingests directly from object stores * Ack notifications of undesired type * Add docs about situations where messages require a DLQ * Fix integ test after rebase
- Loading branch information
Showing
62 changed files
with
4,968 additions
and
773 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
terraform { | ||
required_version = "1.7.5" | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 5.39.1" | ||
} | ||
} | ||
} | ||
|
||
provider "aws" { | ||
region = "us-east-1" | ||
default_tags { | ||
tags = { | ||
provisioner = "terraform" | ||
author = "Quickwit" | ||
} | ||
} | ||
} | ||
|
||
locals { | ||
sqs_notification_queue_name = "qw-tuto-s3-event-notifications" | ||
source_bucket_name = "qw-tuto-source-bucket" | ||
} | ||
|
||
resource "aws_s3_bucket" "file_source" { | ||
bucket_prefix = local.source_bucket_name | ||
force_destroy = true | ||
} | ||
|
||
data "aws_iam_policy_document" "sqs_notification" { | ||
statement { | ||
effect = "Allow" | ||
|
||
principals { | ||
type = "*" | ||
identifiers = ["*"] | ||
} | ||
|
||
actions = ["sqs:SendMessage"] | ||
resources = ["arn:aws:sqs:*:*:${local.sqs_notification_queue_name}"] | ||
|
||
condition { | ||
test = "ArnEquals" | ||
variable = "aws:SourceArn" | ||
values = [aws_s3_bucket.file_source.arn] | ||
} | ||
} | ||
} | ||
|
||
|
||
resource "aws_sqs_queue" "s3_events" { | ||
name = local.sqs_notification_queue_name | ||
policy = data.aws_iam_policy_document.sqs_notification.json | ||
|
||
redrive_policy = jsonencode({ | ||
deadLetterTargetArn = aws_sqs_queue.s3_events_deadletter.arn | ||
maxReceiveCount = 5 | ||
}) | ||
} | ||
|
||
resource "aws_sqs_queue" "s3_events_deadletter" { | ||
name = "${locals.sqs_notification_queue_name}-deadletter" | ||
} | ||
|
||
resource "aws_sqs_queue_redrive_allow_policy" "s3_events_deadletter" { | ||
queue_url = aws_sqs_queue.s3_events_deadletter.id | ||
|
||
redrive_allow_policy = jsonencode({ | ||
redrivePermission = "byQueue", | ||
sourceQueueArns = [aws_sqs_queue.s3_events.arn] | ||
}) | ||
} | ||
|
||
resource "aws_s3_bucket_notification" "bucket_notification" { | ||
bucket = aws_s3_bucket.file_source.id | ||
|
||
queue { | ||
queue_arn = aws_sqs_queue.s3_events.arn | ||
events = ["s3:ObjectCreated:*"] | ||
} | ||
} | ||
|
||
data "aws_iam_policy_document" "quickwit_node" { | ||
statement { | ||
effect = "Allow" | ||
actions = [ | ||
"sqs:ReceiveMessage", | ||
"sqs:DeleteMessage", | ||
"sqs:ChangeMessageVisibility", | ||
"sqs:GetQueueAttributes", | ||
] | ||
resources = [aws_sqs_queue.s3_events.arn] | ||
} | ||
statement { | ||
effect = "Allow" | ||
actions = ["s3:GetObject"] | ||
resources = ["${aws_s3_bucket.file_source.arn}/*"] | ||
} | ||
} | ||
|
||
resource "aws_iam_user" "quickwit_node" { | ||
name = "quickwit-filesource-tutorial" | ||
path = "/system/" | ||
} | ||
|
||
resource "aws_iam_user_policy" "quickwit_node" { | ||
name = "quickwit-filesource-tutorial" | ||
user = aws_iam_user.quickwit_node.name | ||
policy = data.aws_iam_policy_document.quickwit_node.json | ||
} | ||
|
||
resource "aws_iam_access_key" "quickwit_node" { | ||
user = aws_iam_user.quickwit_node.name | ||
} | ||
|
||
output "source_bucket_name" { | ||
value = aws_s3_bucket.file_source.bucket | ||
|
||
} | ||
|
||
output "notification_queue_url" { | ||
value = aws_sqs_queue.s3_events.id | ||
} | ||
|
||
output "quickwit_node_access_key_id" { | ||
value = aws_iam_access_key.quickwit_node.id | ||
sensitive = true | ||
} | ||
|
||
output "quickwit_node_secret_access_key" { | ||
value = aws_iam_access_key.quickwit_node.secret | ||
sensitive = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.