-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Add SNS subscription filter #2806
Conversation
Could anyone review this PR? |
acceptance test has not passed yet
|
@radeksimko Would you help me fix this? |
@yohei1126 There are helpful things in |
Thanks. I fixed acc test.
|
Probably you should set the below theree
|
@atsushi-ishibashi Thanks. I add some attributes you mentioned above. |
@radeksimko Would you review this PR? |
@radeksimko Would you check this? All of existing and new acceptance tests have already passed. Everything works well. |
Do you guys have an estimate when this is going live? We are in desperate need for it 👍 |
@radeksimko Everybody needs this feature! Would you review this PR? |
@bflad Could you review this? |
@radeksimko Would you review this PR? |
Hi, everyone. Just to provide an update here, we are actively working on only crash and bug fixes this week for a v1.7.1 release. I cannot guarantee a timeframe for review/acceptance of this PR until after then, but we do see this PR and will get to it. PS: Please vote on issues/PRs with 👍 reactions on the original post. We use this to help us prioritize our work. |
@bflad Thanks. I am waiting for your review. Please let me know if I can help you. |
@bflad any update? |
It would be great if this PR is merged this month :) |
@bflad could you check it? |
1 similar comment
@bflad could you check it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yohei1126 this is off to a great start! Thanks for submitting this functionality, for which lots of people are excited.
Please see my feedback below (mostly just testing related), letting me know if you have any questions and when its good to look at again or if you do not have time to address these! 🚀
_, err := snsconn.SetSubscriptionAttributes(req) | ||
|
||
if err != nil { | ||
return fmt.Errorf("Unable to set filter policy attribute on subscription") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: We should probably return the err as well so people know why this happened 😄
return fmt.Errorf("Unable to set filter policy attribute on subscription: %s", err)
@@ -31,6 +31,25 @@ func TestAccAWSSNSTopicSubscription_basic(t *testing.T) { | |||
}) | |||
} | |||
|
|||
func TestAccAWSSNSTopicSubscription_attributes(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please adjust this acceptance test:
- Rename to
_filterPolicy
(there are otherattributes
we can/should be testing) - Add an update step and verify attributes
For the second item, you can check out TestAccAWSIAMUserPolicy_multiplePolicies
for an example of this in action.
@@ -157,6 +207,25 @@ resource "aws_sns_topic_subscription" "test_subscription" { | |||
`, i, i) | |||
} | |||
|
|||
func testAccAWSSNSTopicSubscriptionConfig_attributes(i int) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In line with renaming the test itself, we should update this as well please: _filterPolicy
topic_arn = "${aws_sns_topic.test_topic.arn}" | ||
protocol = "sqs" | ||
endpoint = "${aws_sqs_queue.test_queue.arn}" | ||
filter_policy = "{\"key1\": [\"val1\"], \"key2\": [\"val2\"]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you parameterize the filter_policy here so we can easily add an update step to the acceptance testing? filter_policy = %s
We can easily handle the extra quoting conversions (and checking the attribute is properly set to the right value in the state) with strconv.Quote()
in the test function. Check out TestAccAWSIAMUserPolicy_multiplePolicies
for an example of this in action. 😄
@@ -124,6 +143,37 @@ func testAccCheckAWSSNSTopicSubscriptionExists(n string) resource.TestCheckFunc | |||
} | |||
} | |||
|
|||
func testAccCheckAWSSNSTopicSubscriptionAttributesExists(n string) resource.TestCheckFunc { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is unnecessary, see above. 😄
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSSNSTopicExists("aws_sns_topic.test_topic"), | ||
testAccCheckAWSSNSTopicSubscriptionExists("aws_sns_topic_subscription.test_subscription"), | ||
testAccCheckAWSSNSTopicSubscriptionAttributesExists("aws_sns_topic_subscription.test_subscription"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be done much easier with using some of our acceptance testing helper functions. Can you please switch them over to something like this (once the filter_policy is parameterized in the configuration)?
resource.TestCheckResourceAttr("aws_sns_topic_subscription", "filter_policy", strconv.Quote(filterPolicy)),
Sorry. The test failed.
|
|
@bflad I fixed the test. Could you check it again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM -- thanks for the extra effort, very clean! 🚀
make testacc TEST=./aws TESTARGS='-run=TestAccAWSSNSTopicSubscription'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSSNSTopicSubscription -timeout 120m
=== RUN TestAccAWSSNSTopicSubscription_importBasic
--- PASS: TestAccAWSSNSTopicSubscription_importBasic (17.75s)
=== RUN TestAccAWSSNSTopicSubscription_basic
--- PASS: TestAccAWSSNSTopicSubscription_basic (15.72s)
=== RUN TestAccAWSSNSTopicSubscription_filterPolicy
--- PASS: TestAccAWSSNSTopicSubscription_filterPolicy (28.20s)
=== RUN TestAccAWSSNSTopicSubscription_autoConfirmingEndpoint
--- PASS: TestAccAWSSNSTopicSubscription_autoConfirmingEndpoint (45.97s)
=== RUN TestAccAWSSNSTopicSubscription_autoConfirmingSecuredEndpoint
--- PASS: TestAccAWSSNSTopicSubscription_autoConfirmingSecuredEndpoint (75.95s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 183.649s
This has been released in terraform-provider-aws version 1.9.0. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
We found a problem with the functionality and I've created an issue for it |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
fixes #2554
https://docs.aws.amazon.com/sns/latest/dg/message-filtering.html
Applying a Filter Policy with the AWS CLI
Acceptance test for this has passed.