Skip to content

Commit 7b2280d

Browse files
Merge pull request #53 from scribd/enable-filter-policy-sns-subscription
feat: enabling filter for sqs sns subscription
2 parents 9163b09 + ea5e2c0 commit 7b2280d

File tree

5 files changed

+39
-35
lines changed

5 files changed

+39
-35
lines changed

autotagging.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ resource "aws_sqs_queue" "auto_tagging" {
4949
}
5050

5151
resource "aws_sns_topic_subscription" "auto_tagging" {
52-
count = var.enable_auto_tagging == true ? var.sns_topic_arn == "" ? 0 : 1 : 0
53-
52+
count = var.enable_auto_tagging == true ? var.sns_topic_arn == "" ? 0 : 1 : 0
5453
topic_arn = var.sns_topic_arn
5554
protocol = "sqs"
5655
endpoint = aws_sqs_queue.auto_tagging[0].arn

glue_create.tf

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,12 @@ resource "aws_sqs_queue_redrive_allow_policy" "terraform_queue_redrive_allow_pol
105105
}
106106

107107
resource "aws_sns_topic_subscription" "glue_create_sns_sub" {
108-
count = var.enable_glue_create ? 1 : 0
109-
110-
topic_arn = var.glue_create_config.sns_topic_arn
111-
protocol = "sqs"
112-
endpoint = aws_sqs_queue.glue_create[0].arn
108+
count = var.enable_glue_create ? 1 : 0
109+
filter_policy = var.glue_create_config.sns_subcription_filter_policy
110+
filter_policy_scope = var.glue_create_config.filter_policy_scope
111+
topic_arn = var.glue_create_config.sns_topic_arn
112+
protocol = "sqs"
113+
endpoint = aws_sqs_queue.glue_create[0].arn
113114
}
114115

115116
data "aws_iam_policy_document" "glue_create_assume" {

glue_sync.tf

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,12 @@ resource "aws_sqs_queue_redrive_allow_policy" "glue_syncredrive_allow_policy" {
6969
}
7070

7171
resource "aws_sns_topic_subscription" "glue_sync_sns_sub" {
72-
count = var.enable_glue_sync ? 1 : 0
73-
74-
topic_arn = var.glue_sync_config.sns_topic_arn
75-
protocol = "sqs"
76-
endpoint = aws_sqs_queue.glue_sync[0].arn
72+
count = var.enable_glue_sync ? 1 : 0
73+
filter_policy = var.glue_sync_config.sns_subcription_filter_policy
74+
filter_policy_scope = var.glue_sync_config.filter_policy_scope
75+
topic_arn = var.glue_sync_config.sns_topic_arn
76+
protocol = "sqs"
77+
endpoint = aws_sqs_queue.glue_sync[0].arn
7778
}
7879

7980
data "aws_iam_policy_document" "glue_sync_assume" {

main.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,7 @@ resource "aws_sqs_queue" "this_DL" {
263263
}
264264

265265
resource "aws_sns_topic_subscription" "this_sns_sub" {
266-
count = var.sns_topic_arn == "" ? 0 : 1
267-
266+
count = var.sns_topic_arn == "" ? 0 : 1
268267
topic_arn = var.sns_topic_arn
269268
protocol = "sqs"
270269
endpoint = local.enable_group_events ? aws_sqs_queue.group_events_lambda_sqs[0].arn : aws_sqs_queue.this_sqs[0].arn

variables.tf

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -291,18 +291,20 @@ variable "enable_schema_evolution" {
291291

292292
variable "glue_create_config" {
293293
type = object({
294-
athena_workgroup_name = string // Name of AWS Athena workgroup
295-
athena_data_source = string // Arn name of AWS Athena data source (catalog)
296-
athena_bucket_name = string // name of AWS Athena bucket.
297-
lambda_s3_key = string // lambda s3 key - lambda path on S3 and file name filename
298-
lambda_s3_bucket = string // lambda s3 bucket where lambda is stored
299-
lambda_function_name = string // lambda function name
300-
path_regex = string // regexp for mapping s3 path to database/table
301-
sns_topic_arn = string // sns topic arn with s3 events (source for lambda)
302-
sqs_queue_name = string // name of sqs queue for glue-sync lambda
303-
sqs_queue_name_dl = string // name dead letter sqs que with not processed s3 events
304-
iam_role_name = string // lambda role name
305-
iam_policy_name = string // lambda policy name
294+
athena_workgroup_name = string // Name of AWS Athena workgroup
295+
athena_data_source = string // Arn name of AWS Athena data source (catalog)
296+
athena_bucket_name = string // name of AWS Athena bucket.
297+
lambda_s3_key = string // lambda s3 key - lambda path on S3 and file name filename
298+
lambda_s3_bucket = string // lambda s3 bucket where lambda is stored
299+
lambda_function_name = string // lambda function name
300+
path_regex = string // regexp for mapping s3 path to database/table
301+
sns_topic_arn = string // sns topic arn with s3 events (source for lambda)
302+
sqs_queue_name = string // name of sqs queue for glue-sync lambda
303+
sqs_queue_name_dl = string // name dead letter sqs que with not processed s3 events
304+
iam_role_name = string // lambda role name
305+
iam_policy_name = string // lambda policy name
306+
sns_subcription_filter_policy = string // sns subcription filter policy
307+
filter_policy_scope = string // sns subcription filter policy scope
306308
})
307309
description = "Configuration of glue-create lambda"
308310
}
@@ -315,15 +317,17 @@ variable "enable_glue_sync" {
315317

316318
variable "glue_sync_config" {
317319
type = object({
318-
lambda_s3_key = string // lambda s3 key - lambda path on S3 and file name filename
319-
lambda_s3_bucket = string // lambda s3 bucket where lambda is stored
320-
lambda_function_name = string // lambda function name
321-
path_regex = string // regexp for mapping s3 path to database/table
322-
sns_topic_arn = string // sns topic arn with s3 events (source for lambda)
323-
sqs_queue_name = string // name of sqs queue for glue-sync lambda
324-
sqs_queue_name_dl = string // name dead letter sqs que with not processed s3 events
325-
iam_role_name = string // lambda role name
326-
iam_policy_name = string // lambda policy name
320+
lambda_s3_key = string // lambda s3 key - lambda path on S3 and file name filename
321+
lambda_s3_bucket = string // lambda s3 bucket where lambda is stored
322+
lambda_function_name = string // lambda function name
323+
path_regex = string // regexp for mapping s3 path to database/table
324+
sns_topic_arn = string // sns topic arn with s3 events (source for lambda)
325+
sqs_queue_name = string // name of sqs queue for glue-sync lambda
326+
sqs_queue_name_dl = string // name dead letter sqs que with not processed s3 events
327+
iam_role_name = string // lambda role name
328+
iam_policy_name = string // lambda policy name
329+
sns_subcription_filter_policy = string // sns subcription filter policy
330+
filter_policy_scope = string // sns subcription filter policy scope
327331
})
328332
description = "Configuration of glue-sync lambda"
329333
}

0 commit comments

Comments
 (0)