i try to create sqs queue and attach access policy to it, The policy is of type "data" - no actual resource is created , its just attached to the newly created sqs queue.
╷
│ Error: Cycle: data.aws_iam_policy_document.sqs_vote_policy, aws_sqs_queue.sqs_vote
│
the tf code:
resource "aws_sqs_queue" "sqs_vote" {
name = "sqs-erjan"
delay_seconds = 0
message_retention_seconds = 86400
receive_wait_time_seconds = 0
policy = data.aws_iam_policy_document.sqs_vote_policy.json
}
data "aws_iam_policy_document" "sqs_vote_policy" {
policy_id = "__default_policy_ID"
statement {
sid = "__console_sub_0"
actions = ["SQS:SendMessage"]
resources = [aws_sqs_queue.sqs_vote.arn]
principals {
type = "AWS"
identifiers = ["*"]
}
effect = "Allow"
condition {
test = "ArnLike"
variable = "AWS:SourceArn"
values = [
aws_sns_topic.vote_sns.arn
]
}
}
statement {
sid = "__owner_statement"
actions = ["SQS:*"]
resources = [aws_sqs_queue.sqs_vote.arn]
principals {
type = "arn:aws:iam::025416187662:root"
identifiers = ["*"]
}
effect = "Allow"
}
# i put depends on to make sure it runs first - but it still gives cycle error
depends_on = [
aws_sqs_queue.sqs_vote,aws_sns_topic.vote_sns
]
}
how to fix it?