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

[Bug]: aws_sns_topic fails to plan if the deployed resource policy references IAM roles which have been deleted or recreated #38178

Open
rhowe opened this issue Jun 28, 2024 · 2 comments
Labels
bug Addresses a defect in current functionality. service/iam Issues and PRs that pertain to the iam service. service/sns Issues and PRs that pertain to the sns service.

Comments

@rhowe
Copy link

rhowe commented Jun 28, 2024

Terraform Core Version

1.5.7

AWS Provider Version

5.10.0

Affected Resource(s)

  • aws_sns_topic

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

Error: reading SNS Topic (arn:...): contains invalid principals

Terraform Configuration Files

# 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

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

@rhowe rhowe added the bug Addresses a defect in current functionality. label Jun 28, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • 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.

@github-actions github-actions bot added service/iam Issues and PRs that pertain to the iam service. service/sns Issues and PRs that pertain to the sns service. labels Jun 28, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Jun 28, 2024
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Jul 2, 2024
@rhowe
Copy link
Author

rhowe commented Jul 7, 2024

Also confirmed on provider 5.55.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/iam Issues and PRs that pertain to the iam service. service/sns Issues and PRs that pertain to the sns service.
Projects
None yet
Development

No branches or pull requests

2 participants