-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Regression: SNS topic subscription is not recreated after SNS topic delete/recreate #25059
Comments
Hi @BGarber42, did this previously work for you without the ? Can you give the provider version number where this worked? From looking at the code in the commit you referenced (i.e., b8052fdb8a02a1e6cb2ae45fde6d694dc8443c2e), there aren't functional changes to what the provider is doing. The function I'll look into this more, since it is clearly a problem. One problem is that even when an SNS topic is recreated, the ARN is the same, so Terraform doesn't see the change. |
Can you provide some more information, please, @BGarber42? I can't reproduce the problem. Are you both destroying and recreating the SNS Topic outside of Terraform? When I create the SNS Topic and Subscriptions in Terraform, then use the AWS Console to destroy the Topic,
|
Hi @BGarber42, since I haven't heard back, I'm going to assume that this happens when the SNS topic is either deleted or recreated outside of Terraform, and work on a fix based on that assumption. If this is not the case, please let me know what triggers the error that you're seeing. tl;dr: As a workaround, use The basic problem here is that the SNS Topic ARN is based exclusively on the SNS Topic name. If a topic is destroyed and recreated with the same name, the ARN will therefore be the same. If Terraform handles the recreation, it will also recreate the subscription. However, if the topic is recreated outside of Terraform, the provider cannot use the ARN value to detect that it has changed. In most cases, the provider could make other API calls to detect the change. The calls As it stands, there is no mechanism in the AWS API to identify orphaned subscriptions. Even in the AWS Console, orphaned subscriptions will still link back to the recreated topic, even though the topic does not list it as a subscription. |
Sorry for the delayed response, some reason this ticket notifications got filtered into spam. It's not being modified outside of terraform, just in a separate workspace. Workspace A sets up the SNS Topics, then any number of other workspaces may create SQS queues which subscribe to the topic. If the primary workspace gets redeployed, SQS queues still think they're subscribed when they're not. |
To reproduce, see the original ticket #9645 which still works. Seems I liked the wrong, regression commit. I think it is actually this commit which revered the changes from #14101.
Which can be shown with the output comparing
|
Or here's the output of an example run where Terraform thinks it's okay, when it isn't.
|
Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you! |
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. |
Community Note
Terraform CLI and Terraform AWS Provider Version
Terraform version: 1.1.9
AWS Provider: 4.13.0
Affected Resource(s)
Terraform Configuration Files
Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.
Debug Output
Panic Output
Expected Behavior
Terraform should recreate the SNS subscription
Actual Behavior
Terraform does not recreate the SNS subscription
Steps to Reproduce
Important Factoids
References
SubscriptionByARN
to see actual current active subscriptions to a given topic. This is due to the fact that there can be up to a 72 hours delay for orphaned subscriptions to disappear from the list of subscriptions. You can still retrieve attributes for these orphaned subscriptions.FindSubscriptionAttributesByARN
which returns attributes of an Subscription regardless if it is orphaned or not, thus preventing terraform from recreating the subscription properly.The text was updated successfully, but these errors were encountered: