Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to determine service/operation name to be authorized when using API Gateway to POST to SQS

Following the accepted answer here, I tried to configure an API Gateway to send messages to SQS using POST instead of GET (I was able to make GET work). When using POST, I get this response:

<AccessDeniedException>
  <Message>Unable to determine service/operation name to be authorized</Message>
</AccessDeniedException>

This is how my mapping template is configured

#set($clientKey = $input.params('clientkey'))
#set($url = "https://sqs.us-east-2.amazonaws.com/XXXXXXXX/SomeQueuePrefix-${clientKey}-SomeQueueEnvironment.fifo")
Action=SendMessage##
&QueueUrl=$util.urlEncode($url)##
&MessageGroupId=$input.params('messageGroupId')##
&MessageDeduplicationId=1##
&MessageBody=$util.urlEncode($input.body)

It looks like it maps the body correctly

Wed Nov 14 20:39:44 UTC 2018 : Endpoint request body after transformations: Action=SendMessage&QueueUrl=https%3A%2F%2Fsqs.us-east-2.amazonaws.com%2FXXXXXXXXX%2FSomeQueuePrefix-TEST-SomeQueueEnvironment.fifo&MessageGroupId=3&MessageDeduplicationId=1&MessageBody=%7B%0A++++%22configurationId%22%3A+1%0A%7D
Wed Nov 14 20:39:44 UTC 2018 : Sending request to https://sqs.us-east-1.amazonaws.com//

Screenshot of my Integration Request setup

My IAM policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Resource": [
                "arn:aws:sqs:us-east-1:XXXXXXXXX:CADAUTO-*-DEV.fifo"
            ],
            "Action": [
                "sqs:SendMessage",
                "sqs:ReceiveMessage",
                "sqs:DeleteMessage"
            ]
        }
    ]
}

Can anybody see why this isn't working?

like image 752
Eric Wood Avatar asked Dec 18 '22 20:12

Eric Wood


1 Answers

SQS expects content type to be 'Content-Type' to 'application/x-www-form-urlencoded'. setting this in HTTP headers in API gateway settings solved my problem.

like image 125
Hari Krishnan Avatar answered Jan 04 '23 17:01

Hari Krishnan