-
Notifications
You must be signed in to change notification settings - Fork 14
Support SQS Queue URL for continuous ingestion in S3 #388
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
Open
EvandroLG
wants to merge
8
commits into
main
Choose a base branch
from
feat/unordered-mode
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9d7c33f
feat(clickpipe): support SQS queue_url for event-based continuous ing…
EvandroLG 5892b9c
feat(clickpipe): validate and wire queue_url for S3 continuous ingestion
EvandroLG e950174
feat(clickpipe): improve validation check for authentication type
EvandroLG 7a75a20
Update pkg/resource/clickpipe.go
EvandroLG d8705e2
feat(clickpipe): improve validation check for authentication type
EvandroLG 26ff21b
examples(clickpipe): add continuous ingestion example with S3 + SQS u…
EvandroLG 963a6de
examples(clickpipe): add continuous ingestion example with S3 + SQS u…
EvandroLG d6737e2
docs(clickpipes): add unordered mode terminology to clickpipe examples
EvandroLG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
examples/clickpipe/object_storage_s3_sqs_iam_role/README.md
This file contains hidden or 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,11 @@ | ||
| ## ClickPipe Object Storage with S3/SQS/IAM role example | ||
|
|
||
| This example demonstrates how to deploy a ClickPipe with an S3 bucket as the input source with continuous ingestion using SQS event notifications, authenticated with an IAM role. | ||
|
|
||
| This setup enables event-based ingestion where new files are detected via S3 event notifications sent to an SQS queue, rather than polling S3 for new files. IAM role authentication is only available for AWS ClickHouse Cloud services and is the recommended authentication method. | ||
|
|
||
| ## How to run | ||
|
|
||
| - Rename `variables.sample.tfvars` to `variables.tfvars` and fill in all needed data. | ||
| - Run `terraform init` | ||
| - Run `terraform <plan|apply> -var-file=variables.tfvars` | ||
106 changes: 106 additions & 0 deletions
106
examples/clickpipe/object_storage_s3_sqs_iam_role/main.tf
This file contains hidden or 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,106 @@ | ||
| variable "organization_id" {} | ||
| variable "token_key" {} | ||
| variable "token_secret" {} | ||
|
|
||
| variable "service_id" { | ||
| description = "ClickHouse Cloud service ID" | ||
| } | ||
|
|
||
| variable "bucket_url" { | ||
| description = "S3 bucket URL pattern (e.g., s3://my-bucket/path/*.json)" | ||
| } | ||
|
|
||
| variable "sqs_queue_url" { | ||
| description = "SQS queue URL for S3 event notifications (e.g., https://sqs.us-east-1.amazonaws.com/123456789012/my-queue)" | ||
| } | ||
|
|
||
| variable "iam_role" { | ||
| description = "ARN of the IAM role with permissions to read from S3 and receive SQS messages" | ||
| sensitive = true | ||
| } | ||
|
|
||
| # S3 ClickPipe with continuous ingestion using SQS event notifications | ||
| # This example demonstrates event-based continuous ingestion where new files | ||
| # are detected via S3 event notifications sent to an SQS queue, rather than | ||
| # polling S3 for new files in lexicographical order. | ||
| resource "clickhouse_clickpipe" "s3_sqs_continuous" { | ||
| name = "S3 Continuous ClickPipe with SQS (IAM Role)" | ||
| service_id = var.service_id | ||
|
|
||
| source = { | ||
| object_storage = { | ||
| type = "s3" | ||
| format = "JSONEachRow" | ||
| url = var.bucket_url | ||
|
|
||
| # Enable continuous ingestion with event-based processing | ||
| is_continuous = true | ||
| queue_url = var.sqs_queue_url | ||
|
|
||
| # IAM role authentication - recommended for AWS services | ||
| authentication = "IAM_ROLE" | ||
| iam_role = var.iam_role | ||
| } | ||
| } | ||
|
|
||
| destination = { | ||
| table = "s3_events_data" | ||
| managed_table = true | ||
|
|
||
| table_definition = { | ||
| engine = { | ||
| type = "MergeTree" | ||
| } | ||
|
|
||
| sorting_key = ["timestamp"] | ||
| } | ||
|
|
||
| columns = [ | ||
| { | ||
| name = "id" | ||
| type = "String" | ||
| }, | ||
| { | ||
| name = "timestamp" | ||
| type = "DateTime64(3)" | ||
| }, | ||
| { | ||
| name = "event_type" | ||
| type = "String" | ||
| }, | ||
| { | ||
| name = "data" | ||
| type = "String" | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| field_mappings = [ | ||
| { | ||
| source_field = "id" | ||
| destination_field = "id" | ||
| }, | ||
| { | ||
| source_field = "timestamp" | ||
| destination_field = "timestamp" | ||
| }, | ||
| { | ||
| source_field = "event_type" | ||
| destination_field = "event_type" | ||
| }, | ||
| { | ||
| source_field = "data" | ||
| destination_field = "data" | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| output "clickpipe_id" { | ||
| value = clickhouse_clickpipe.s3_sqs_continuous.id | ||
| description = "The ID of the created ClickPipe" | ||
| } | ||
|
|
||
| output "clickpipe_state" { | ||
| value = clickhouse_clickpipe.s3_sqs_continuous.state | ||
| description = "The current state of the ClickPipe" | ||
| } |
13 changes: 13 additions & 0 deletions
13
examples/clickpipe/object_storage_s3_sqs_iam_role/provider.tf
This file contains hidden or 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,13 @@ | ||
| terraform { | ||
| required_providers { | ||
| clickhouse = { | ||
| source = "ClickHouse/clickhouse" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| provider "clickhouse" { | ||
| organization_id = var.organization_id | ||
| token_key = var.token_key | ||
| token_secret = var.token_secret | ||
| } |
14 changes: 14 additions & 0 deletions
14
examples/clickpipe/object_storage_s3_sqs_iam_role/provider.tf.template.alpha
This file contains hidden or 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,14 @@ | ||
| terraform { | ||
| required_providers { | ||
| clickhouse = { | ||
| version = "${CLICKHOUSE_TERRAFORM_PROVIDER_VERSION}" | ||
| source = "ClickHouse/clickhouse" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| provider "clickhouse" { | ||
| organization_id = var.organization_id | ||
| token_key = var.token_key | ||
| token_secret = var.token_secret | ||
| } |
13 changes: 13 additions & 0 deletions
13
examples/clickpipe/object_storage_s3_sqs_iam_role/variables.sample.tfvars
This file contains hidden or 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,13 @@ | ||
| # These keys are for example only and won't work when pointed to a deployed ClickHouse OpenAPI server | ||
| organization_id = "aee076c1-3f83-4637-95b1-ad5a0a825b71" | ||
| token_key = "avhj1U5QCdWAE9CA9" | ||
| token_secret = "4b1dROiHQEuSXJHlV8zHFd0S7WQj7CGxz5kGJeJnca" | ||
| service_id = "aee076c1-3f83-4637-95b1-ad5a0a825b71" | ||
|
|
||
| bucket_url = "s3://mybucket/path/*.json" | ||
|
|
||
| # SQS queue URL must follow the format: https://sqs.{region}.amazonaws.com/{account-id}/{queue-name} | ||
| sqs_queue_url = "https://sqs.us-east-1.amazonaws.com/123456789012/my-clickpipe-queue" | ||
|
|
||
| # IAM role ARN with permissions to read S3 and receive SQS messages | ||
| iam_role = "arn:aws:iam::123456789012:role/ClickPipeRole" |
11 changes: 11 additions & 0 deletions
11
examples/clickpipe/object_storage_s3_sqs_iam_user/README.md
This file contains hidden or 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,11 @@ | ||
| ## ClickPipe Object Storage with S3/SQS/IAM user example | ||
|
|
||
| This example demonstrates how to deploy a ClickPipe with an S3 bucket as the input source with continuous ingestion using SQS event notifications, authenticated with an IAM user. | ||
|
|
||
| This setup enables event-based ingestion where new files are detected via S3 event notifications sent to an SQS queue, rather than polling S3 for new files. | ||
|
|
||
| ## How to run | ||
|
|
||
| - Rename `variables.sample.tfvars` to `variables.tfvars` and fill in all needed data. | ||
| - Run `terraform init` | ||
| - Run `terraform <plan|apply> -var-file=variables.tfvars` |
114 changes: 114 additions & 0 deletions
114
examples/clickpipe/object_storage_s3_sqs_iam_user/main.tf
This file contains hidden or 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,114 @@ | ||
| variable "organization_id" {} | ||
| variable "token_key" {} | ||
| variable "token_secret" {} | ||
|
|
||
| variable "service_id" { | ||
| description = "ClickHouse Cloud service ID" | ||
| } | ||
|
|
||
| variable "bucket_url" { | ||
| description = "S3 bucket URL pattern (e.g., s3://my-bucket/path/*.json)" | ||
| } | ||
|
|
||
| variable "sqs_queue_url" { | ||
| description = "SQS queue URL for S3 event notifications (e.g., https://sqs.us-east-1.amazonaws.com/123456789012/my-queue)" | ||
| } | ||
|
|
||
| variable "iam_access_key_id" { | ||
| description = "AWS IAM access key ID with permissions to read from S3 and receive SQS messages" | ||
| sensitive = true | ||
| } | ||
|
|
||
| variable "iam_secret_key" { | ||
| description = "AWS IAM secret access key" | ||
| sensitive = true | ||
| } | ||
|
|
||
| # S3 ClickPipe with continuous ingestion using SQS event notifications | ||
| # This example demonstrates event-based continuous ingestion where new files | ||
| # are detected via S3 event notifications sent to an SQS queue, rather than | ||
| # polling S3 for new files in lexicographical order. | ||
| resource "clickhouse_clickpipe" "s3_sqs_continuous" { | ||
| name = "S3 Continuous ClickPipe with SQS (IAM User)" | ||
| service_id = var.service_id | ||
|
|
||
| source = { | ||
| object_storage = { | ||
| type = "s3" | ||
| format = "JSONEachRow" | ||
| url = var.bucket_url | ||
|
|
||
| # Enable continuous ingestion with event-based processing | ||
| is_continuous = true | ||
| queue_url = var.sqs_queue_url | ||
|
|
||
| # IAM user authentication | ||
| authentication = "IAM_USER" | ||
| access_key = { | ||
| access_key_id = var.iam_access_key_id | ||
| secret_key = var.iam_secret_key | ||
| } | ||
| } | ||
| } | ||
|
|
||
| destination = { | ||
| table = "s3_events_data" | ||
| managed_table = true | ||
|
|
||
| table_definition = { | ||
| engine = { | ||
| type = "MergeTree" | ||
| } | ||
|
|
||
| sorting_key = ["timestamp"] | ||
| } | ||
|
|
||
| columns = [ | ||
| { | ||
| name = "id" | ||
| type = "String" | ||
| }, | ||
| { | ||
| name = "timestamp" | ||
| type = "DateTime64(3)" | ||
| }, | ||
| { | ||
| name = "event_type" | ||
| type = "String" | ||
| }, | ||
| { | ||
| name = "data" | ||
| type = "String" | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| field_mappings = [ | ||
| { | ||
| source_field = "id" | ||
| destination_field = "id" | ||
| }, | ||
| { | ||
| source_field = "timestamp" | ||
| destination_field = "timestamp" | ||
| }, | ||
| { | ||
| source_field = "event_type" | ||
| destination_field = "event_type" | ||
| }, | ||
| { | ||
| source_field = "data" | ||
| destination_field = "data" | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| output "clickpipe_id" { | ||
| value = clickhouse_clickpipe.s3_sqs_continuous.id | ||
| description = "The ID of the created ClickPipe" | ||
| } | ||
|
|
||
| output "clickpipe_state" { | ||
| value = clickhouse_clickpipe.s3_sqs_continuous.state | ||
| description = "The current state of the ClickPipe" | ||
| } |
13 changes: 13 additions & 0 deletions
13
examples/clickpipe/object_storage_s3_sqs_iam_user/provider.tf
This file contains hidden or 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,13 @@ | ||
| terraform { | ||
| required_providers { | ||
| clickhouse = { | ||
| source = "ClickHouse/clickhouse" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| provider "clickhouse" { | ||
| organization_id = var.organization_id | ||
| token_key = var.token_key | ||
| token_secret = var.token_secret | ||
| } |
14 changes: 14 additions & 0 deletions
14
examples/clickpipe/object_storage_s3_sqs_iam_user/provider.tf.template.alpha
This file contains hidden or 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,14 @@ | ||
| terraform { | ||
| required_providers { | ||
| clickhouse = { | ||
| version = "${CLICKHOUSE_TERRAFORM_PROVIDER_VERSION}" | ||
| source = "ClickHouse/clickhouse" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| provider "clickhouse" { | ||
| organization_id = var.organization_id | ||
| token_key = var.token_key | ||
| token_secret = var.token_secret | ||
| } |
13 changes: 13 additions & 0 deletions
13
examples/clickpipe/object_storage_s3_sqs_iam_user/variables.sample.tfvars
This file contains hidden or 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,13 @@ | ||
| # These keys are for example only and won't work when pointed to a deployed ClickHouse OpenAPI server | ||
| organization_id = "aee076c1-3f83-4637-95b1-ad5a0a825b71" | ||
| token_key = "avhj1U5QCdWAE9CA9" | ||
| token_secret = "4b1dROiHQEuSXJHlV8zHFd0S7WQj7CGxz5kGJeJnca" | ||
| service_id = "aee076c1-3f83-4637-95b1-ad5a0a825b71" | ||
|
|
||
| bucket_url = "s3://mybucket/path/*.json" | ||
|
|
||
| # SQS queue URL must follow the format: https://sqs.{region}.amazonaws.com/{account-id}/{queue-name} | ||
| sqs_queue_url = "https://sqs.us-east-1.amazonaws.com/123456789012/my-clickpipe-queue" | ||
|
|
||
| iam_access_key_id = "AKIAIOSFODNN7EXAMPLE" | ||
| iam_secret_key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.