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

Address issue with maxReceiveCount key in subscription redrive policy #56

Closed

Conversation

userhas404d
Copy link

@userhas404d userhas404d commented Sep 16, 2022

what

  • Address issue with maxReceiveCount key in subscription redrive policy
  • Updates provided example with multiple subscriptions

why

  • I'd like to utilize this module for existing infrastructure that requires an sns topic with multiple subscriptions

maxReceiveCount when provided

Error: error setting SNS Topic Subscription (arn:aws:sns:us-west-2::eg-test-sns.fifo:310f9002-0630-42dc-ba81-1ce9521840d3) attribute (RedrivePolicy): InvalidParameter: Invalid parameter: RedrivePolicy: invalid JSON. Attribute maxReceiveCount is unknown.

references

Copy link
Member

@nitrocode nitrocode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

@userhas404d userhas404d force-pushed the multiple-subscriptions branch from 37df062 to b18b161 Compare September 19, 2022 15:46
main.tf Outdated
Comment on lines 38 to 42
var.redrive_policy_max_receiver_count != null ? {
deadLetterTargetArn = join("", aws_sqs_queue.dead_letter_queue.*.arn)
maxReceiveCount = var.redrive_policy_max_receiver_count
} : {
deadLetterTargetArn = join("", aws_sqs_queue.dead_letter_queue.*.arn)
Copy link
Member

@nitrocode nitrocode Sep 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is simpler.

Suggested change
var.redrive_policy_max_receiver_count != null ? {
deadLetterTargetArn = join("", aws_sqs_queue.dead_letter_queue.*.arn)
maxReceiveCount = var.redrive_policy_max_receiver_count
} : {
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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using anything other than what I have here still raises this error:

Error: error creating SNS Topic Subscription: InvalidParameter: Invalid parameter: Attributes Reason: RedrivePolicy: invalid JSON. Attribute maxReceiveCount is unknown.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this redrive policy may need to be added directly to the sqs queue

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue

Then the redrive policy for sns topic subscription may only support the deadLetterTargetArn

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic_subscription#redrive_policy

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this lines up with these findings:

The only reference I could find for it in the AWS api docs was here, its suspiciously not called out in the boto3 documentation for SNS topic subscriptions nor in the api docs for SNS Subscribe

So are we back to removing the redrive_policy_max_receiver_count input var? And I suppose simplifying the redrive_policy input in aws_sns_topic_subscription.this is in order as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to remove redrive_policy_max_receiver_count. I think we need to add the appropriate redrive_policy to the appropriate resource.

aws_sqs_queue has both deadLetterTargetArn and maxReceiveCount

aws_sns_topic_subscription has only deadLetterTargetArn

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aws_sqs_queue has both deadLetterTargetArn and maxReceiveCount

right, but the only sqs queue we're defining in the root module is the dlq - are you saying you want to include a redrive policy on it? That seems a little redundant, no?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

went ahead and removed input_redrive_policy_max_receiver_count and by extension the maxRecieveCount key from the aws_sns_topic_subscription redrive policy, if you want me add it to the dlq please lmk

@userhas404d userhas404d changed the title Enables multiple subscriptions Address issue with maxReceiveCount key in subscription redrive policy Sep 19, 2022
@nitrocode
Copy link
Member

Please merge from the default branch in order for passing tests

@userhas404d userhas404d force-pushed the multiple-subscriptions branch from 5bccaed to 5dff3d5 Compare September 19, 2022 19:56
@hans-d hans-d added stale This PR has gone stale wip Work in Progress: Not ready for final review or merge and removed wip Work in Progress: Not ready for final review or merge labels Mar 8, 2024
@hans-d
Copy link

hans-d commented Mar 8, 2024

/terratest

@hans-d hans-d closed this Mar 8, 2024
@nitrocode
Copy link
Member

Hmm, not sure why this was closed, but the PR did get stale.

Maybe we just remove this argument as another person ran into the same issue.

PR #89 will supersede this PR 56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale This PR has gone stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attribute maxReceiveCount is unknown
4 participants