Search code examples
terraformamazon-sqsterraform-provider-awsamazon-snsterraform-cloud

terraform cloud SNS SQS subscription cross account different region struck at operation error SNS: GetSubscriptionAttributes https response error


I am trying to create a cross account different region SNS and SQS subscription through terraform cloud. SNS and SQS both created with necessary access policies. But the mistake I did is created the SNS subscription in SQS region instead of SQS region. Now I am trying to revert my changed and remove SNS and SQS I am getting below error. I have reverted all my changes and deleted SQS, SNS through AWS console but still throwing this error.

the main branch is working and I created a new branch from main and adding SNS / SQS cross account resource's. At this point I just want everything back with no SQS / SNS coz I see an example is terraform site which I want to try.

when I do Terraform plan I get below error

aws_sns_topic.XX_topic: Drift detected (delete) ╷ │ Error: reading SNS Topic Subscription (arn:aws:sns:us-east-1:XX:XX-topic:d833a8ef-XXXX-X-XXXX): operation error SNS: GetSubscriptionAttributes, https response error StatusCode: 403, RequestID: cd6cfd6e-XX-XXXX-XX-XX, AuthorizationError: Not authorized to access this subscription │ │ ╵ Operation failed: failed running terraform plan (exit 1)


Solution

  • I did a refresh and got the state list which showed me the old resources and remove the sns topic subscription resource then its all good.

    terraform state terraform state list terraform state list | grep "Kyyword" terraform state rm aws_sns_topic_subscription.XXXXXX terraform plan - it works