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

Added filter_policy and filter_policy_scope functionality to subscribers #87

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/complete/versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 0.13.0"
required_version = ">= 1.3.0"
required_providers {
aws = {
source = "hashicorp/aws"
Expand Down
6 changes: 4 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ resource "aws_sns_topic" "this" {
resource "aws_sns_topic_subscription" "this" {
for_each = local.enabled ? var.subscribers : {}

topic_arn = join("", aws_sns_topic.this.*.arn)
topic_arn = join("", aws_sns_topic.this[*].arn)
protocol = var.subscribers[each.key].protocol
endpoint = var.subscribers[each.key].endpoint
endpoint_auto_confirms = var.subscribers[each.key].endpoint_auto_confirms
filter_policy = var.subscribers[each.key].filter_policy
filter_policy_scope = var.subscribers[each.key].filter_policy_scope
raw_message_delivery = var.subscribers[each.key].raw_message_delivery
redrive_policy = var.sqs_dlq_enabled ? coalesce(var.redrive_policy, jsonencode({
deadLetterTargetArn = join("", aws_sqs_queue.dead_letter_queue.*.arn)
deadLetterTargetArn = join("", aws_sqs_queue.dead_letter_queue[*].arn)
maxReceiveCount = var.redrive_policy_max_receiver_count
})) : null
}
Expand Down
8 changes: 6 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ variable "subscribers" {
# The protocol to use. The possible values for this are: sqs, sms, lambda, application. (http or https are partially supported, see below) (email is an option but is unsupported, see below).
endpoint = string
# The endpoint to send data to, the contents will vary with the protocol. (see below for more information)
endpoint_auto_confirms = bool
endpoint_auto_confirms = optional(bool, false)
# Boolean indicating whether the end point is capable of auto confirming subscription e.g., PagerDuty (default is false)
raw_message_delivery = bool
filter_policy = optional(string, null)
# The filter policy JSON that is assigned to the subscription. For more information, see Amazon SNS Filter Policies.
filter_policy_scope = optional(string, "MessageAttributes")
# The filter policy scope that is assigned to the subscription. Whether the `filter_policy` applies to `MessageAttributes` (default) or `MessageBody`
raw_message_delivery = optional(bool, false)
# Boolean indicating whether or not to enable raw message delivery (the original message is directly passed, not wrapped in JSON with the original message in the message property) (default is false)
}))
description = "Required configuration for subscibres to SNS topic."
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 0.13.0"
required_version = ">= 1.3.0"

required_providers {
aws = {
Expand Down