"queue does not exist" when accessing my SQS queue
Asked Answered
J

1

1

I have an EC2 instance with the below IAM policy attached to its role:

{
    "Statement": [
        ... other Allow statements here
        {
            "Action": "sqs:*",
            "Effect": "Allow",
            "Resource": [
                "arn:aws:sqs:us-east-1:us-east-1:111111111111:automation-document-dev"
            ]
        }
    ],
    "Version": "2012-10-17"
}

automation-document-dev SQS Access policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowSQSS3BucketNotification",
      "Effect": "Allow",
      "Principal": {
        "Service": "s3.amazonaws.com"
      },
      "Action": "sqs:SendMessage",
      "Resource": "arn:aws:sqs:us-east-1:111111111111:automation-document-dev",
      "Condition": {
        "ArnEquals": {
          "aws:SourceArn": "arn:aws:s3:::doc-storage-dev"
        }
      }
    }
  ]
}

When I SSH to the EC2 instance and execute aws sqs get-queue-url --queue-name automation-document-dev

I get this error:

An error occurred (AWS.SimpleQueueService.NonExistentQueue) when calling the GetQueueUrl operation:
The specified queue does not exist or you do not have access to it.

What I am missing here? The IAM role/policy looks like it should have all of the permissions it needs to access the queue (I used get-queue-url action as a test). From what I know, I don't need to change the SQS's Access Policy as long as the EC2 instance role has permission to use the service.

Jonejonell answered 5/9, 2023 at 9:37 Comment(2)
Try adding the region where you have created sqs: aws sqs get-queue-url --queue-name automation-document-dev --region <your_aws_sqs_region>Dusk
Thank you for the suggestion, I did try that but I'm still getting the same errorJonejonell
D
1

You have the wrong resource arn in the iam role policy, it has region added two times:- arn:aws:sqs:us-east-1:us-east-1:111111111111:automation-document-dev. Please change it to: arn:aws:sqs:us-east-1:111111111111:automation-document-dev.

Dusk answered 5/9, 2023 at 17:50 Comment(3)
Oh my god! That was it. I've completely missed that and I've spend half a day on this issue :X Thank you!Jonejonell
@GeorgiKoemdzhiev Glad to know I was able to help, Actually I was trying to replicate the issue with your policies and just found it has the wrong arn.Dusk
Awesome, thank you for spending time on my issue! :)Jonejonell

© 2022 - 2024 — McMap. All rights reserved.