dev
dev

Reputation: 981

API Gateway 200 Ok + Access Denied on SQS only if i use VTL

POST Request in AWS using API-Gateway

following is my integration request mapping template in API Gateway

#set($head = $input.params('anotherTest')))
#set($myValues = ["abc", "pqr"])
#if($myValues.contains($head))
Action=SendMessage&MessageBody=$input.body
#else
#set($context.responseOverride.status = 403)
{"message_fail": $head}
#end

everything works fine if i only use action as :

Action=SendMessage&MessageBody=$input.body

but IF i use an if-else condition as above, i am getting Access denied error with 200 Ok return code:

{
    "Error": {
        "Code": "AccessDenied",
        "Message": "Access to the resource https://sqs.region.amazonaws.com/account123/myqueue is denied.",
        "Type": "Sender"
    },
    "RequestId": "blah-blah-12345"
}

Here "anotherTest" is also defined in method request with --> "Required=True" i Also tried giving full access on SQS+ PowerUser+ KMSFull access and trust policy has lambda and SQS both but no luck.

Also, SQS Access policy is completely open to receive message from anywhere.

any help is much appreciated

Upvotes: 0

Views: 78

Answers (0)

Related Questions