# This has been hand-copied from a restricted environment I can't copy & paste from
# It might have a few silly errors but hopefully is still useful
resource "aws_iam_role" "role" {
name = "role"
}
resource "aws_sns_topic" "topic" {
name = "mytopic"
display_name = "mytopic"
}
resource "aws_sns_topic_policy" "policy" {
arn = aws_sns_topic.topic.arn
policy = jsonencode({
Id = "topic-policy"
Statement = [{
Sid = "sid"
Action = "sns:Subscribe"
Effect = "Allow"
Principal = {
AWS = aws_iam_role.role.arn
}
Resource = aws_sns_topic.topic.arn
]})
}
Steps to Reproduce
This is an approximation of what I was doing to trigger the issue
terraform apply
terraform -target aws_sns_topic.topic plan # Expect to succeed
terraform -target aws_iam_role.role destroy
terraform -target aws_sns_topic.topic plan # Expect to fail when reading the existing topic policy
terraform -target aws_iam_role.role apply
terraform -target aws_sns_topic.topic plan # Expect to fail when reading the existing topic policy
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
Volunteering to Work on This Issue
If you are interested in working on this issue, please leave a comment.
If this would be your first contribution, please review the contribution guide.
Terraform Core Version
1.5.7
AWS Provider Version
5.10.0
Affected Resource(s)
Expected Behavior
A broken policy should have been retrieved from AWS without causing the plan to fail
Actual Behavior
The Terraform run failed with an error when preparing the plan
Relevant Error/Panic Output Snippet
Terraform Configuration Files
Steps to Reproduce
This is an approximation of what I was doing to trigger the issue
Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
None