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

r/aws_sns_topic_subscription: don't set the FilterPolicyScope attribute in unsupported partitions #28253

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
3 changes: 3 additions & 0 deletions .changelog/28253.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_sns_topic_subscription: Fix unsupported `FilterPolicyScope` attribute error in the aws-cn partition
```
8 changes: 8 additions & 0 deletions internal/service/sns/topic_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,16 @@ func normalizeTopicSubscriptionDeliveryPolicy(policy string) ([]byte, error) {
func resourceTopicSubscriptionCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, _ interface{}) error {
hasPolicy := diff.Get("filter_policy").(string) != ""
hasScope := !diff.GetRawConfig().GetAttr("filter_policy_scope").IsNull()
hadScope := diff.Get("filter_policy_scope").(string) != ""

if hasPolicy && !hasScope {
if !hadScope {
// When the filter_policy_scope hasn't been read back from the API,
// don't attempt to set a value. Either the default will be computed
// on the next read, or this is a partition that doesn't support it.
return nil
}

// When the scope is removed from configuration, the API will
// continue reading back the last value so long as the policy
// itself still exists. The expected result would be to revert
Expand Down
2 changes: 2 additions & 0 deletions internal/service/sns/topic_subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,8 @@ resource "aws_sns_topic_subscription" "test" {
protocol = "https"
endpoint = replace(aws_api_gateway_deployment.test.invoke_url, "https://", "https://davematthews:granny@")
endpoint_auto_confirms = true

confirmation_timeout_in_minutes = 3
}
`, rName)
}
Expand Down