-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
132 additions
and
3,783 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
58 changes: 58 additions & 0 deletions
58
tf-module/unity-cumulus/sqs--sns-lambda-connector/sqs-sns-lambda.tf
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,58 @@ | ||
resource "aws_sqs_queue" "dlq" { // https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue | ||
// TODO how to notify admin for failed ingestion? | ||
tags = var.tags | ||
name = "${var.prefix}-dlq-${var.name}" | ||
delay_seconds = 0 | ||
max_message_size = 262144 | ||
message_retention_seconds = 345600 | ||
visibility_timeout_seconds = 300 | ||
receive_wait_time_seconds = 0 | ||
policy = templatefile("${path.module}/sqs_policy.json", { | ||
region: var.aws_region, | ||
roleArn: var.lambda_processing_role_arn, | ||
accountId: var.account_id, | ||
sqsName: "${var.prefix}-dlq-${var.name}", | ||
}) | ||
// redrive_policy = jsonencode({ | ||
// deadLetterTargetArn = aws_sqs_queue.terraform_queue_deadletter.arn | ||
// maxReceiveCount = 4 | ||
// }) | ||
// tags = { | ||
// Environment = "production" | ||
// } | ||
} | ||
|
||
resource "aws_sqs_queue" "main_sqs" { // https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue | ||
name = "${var.prefix}-${var.name}" | ||
delay_seconds = 0 | ||
max_message_size = 262144 | ||
message_retention_seconds = 345600 | ||
visibility_timeout_seconds = var.cool_off // Used as cool off time in seconds. It will wait for 5 min if it fails | ||
receive_wait_time_seconds = 0 | ||
policy = templatefile("${path.module}/sqs_policy.json", { | ||
region: var.aws_region, | ||
roleArn: var.lambda_processing_role_arn, | ||
accountId: var.account_id, | ||
sqsName: "${var.prefix}-${var.name}", | ||
}) | ||
redrive_policy = jsonencode({ | ||
deadLetterTargetArn = aws_sqs_queue.dlq.arn | ||
maxReceiveCount = var.retried_count // How many times it will be retried. | ||
}) | ||
tags = var.tags | ||
} | ||
|
||
resource "aws_sns_topic_subscription" "granules_cnm_ingester_topic_subscription" { // https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic_subscription | ||
topic_arn = var.sns_arn | ||
protocol = "sqs" | ||
endpoint = aws_sqs_queue.main_sqs.arn | ||
# filter_policy_scope = "MessageBody" // MessageAttributes. not using attributes | ||
# filter_policy = templatefile("${path.module}/ideas_api_job_results_filter_policy.json", {}) | ||
} | ||
|
||
resource "aws_lambda_event_source_mapping" "granules_cnm_ingester_queue_lambda_trigger" { // https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping#sqs | ||
event_source_arn = aws_sqs_queue.main_sqs.arn | ||
function_name = var.lambda_arn | ||
batch_size = var.sqs_batch_size | ||
enabled = true | ||
} |
File renamed without changes.
41 changes: 41 additions & 0 deletions
41
tf-module/unity-cumulus/sqs--sns-lambda-connector/variables.tf
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,41 @@ | ||
variable "prefix" { | ||
type = string | ||
} | ||
variable "name" { | ||
type = string | ||
} | ||
variable "sns_arn" { | ||
type = string | ||
} | ||
variable "lambda_arn" { | ||
type = string | ||
} | ||
variable "sqs_batch_size" { | ||
type = number | ||
default = 1 | ||
} | ||
variable "retried_count" { | ||
type = number | ||
default = 3 | ||
} | ||
variable "cool_off" { | ||
type = number | ||
default = 300 | ||
description = "visibility time out for sqs. in seconds" | ||
} | ||
variable "aws_region" { | ||
type = string | ||
default = "us-west-2" | ||
} | ||
variable "tags" { | ||
description = "Tags to be applied to Cumulus resources that support tags" | ||
type = map(string) | ||
default = {} | ||
} | ||
variable "lambda_processing_role_arn" { | ||
type = string | ||
} | ||
variable "account_id" { | ||
type = string | ||
description = "AWS Account ID" | ||
} |
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