How to integrate API gateway with SQS

As in the title. I am trying to integrate the Gateway API method with SQS using cloud formation. What I am missing is the correct URI for SQS. If any of you have already done this, what should the URI look like?

I came up with something similar, but I have no idea where to put SQS ARN

"arn:aws:apigateway:${AWS::Region}:sqs:action/SendMessage" 

Here is the complete method configuration:

 PostMethod: Type: "AWS::ApiGateway::Method" Properties: ApiKeyRequired: "true" HttpMethod: "POST" ResourceId: !Ref "SomeResource" RestApiId: !Ref "SomeRestApi" Integration: IntegrationHttpMethod: "POST" IntegrationResponses: - StatusCode: 200 Type: "AWS" Uri: "arn:aws:apigateway:${AWS::Region}:sqs:action/SendMessage" 

And here is an example URI if you integrate with a lambda function:

 arn:aws:apigateway:us-west-2:lambda:path//2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:function_name/invocations - 
+6
source share
1 answer

To answer my own question. Here's how you integrate SQS as a service proxy in the API gateway:

 PostMethod: Type: "AWS::ApiGateway::Method" Properties: AuthorizationType: "NONE" ApiKeyRequired: "true" HttpMethod: "POST" ResourceId: !Ref "SomeResource" RestApiId: !Ref "RestApi" MethodResponses: - StatusCode: 200 Integration: Credentials: !GetAtt "RestApiRole.Arn" IntegrationHttpMethod: "POST" IntegrationResponses: - StatusCode: 200 Type: "AWS" Uri: !Sub "arn:aws:apigateway:${AWS::Region}:sqs:action/SendMessage" RequestParameters: integration.request.querystring.QueueUrl: !Sub "'${SomeQueue}'" integration.request.querystring.MessageBody: "method.request.body" 

Finally, I found the answers to all the questions in different documents. RTFM, I think.

EDIT:

and here is the RestApiRole code:

 RestApiRole: Type: "AWS::IAM::Role" Properties: AssumeRolePolicyDocument: Version: "2012-10-17" Statement: - Action: - "sts:AssumeRole" Principal: Service: - "apigateway.amazonaws.com" Effect: "Allow" Policies: - PolicyName: "InvokeLambda" PolicyDocument: Version: "2012-10-17" Statement: - Action: - "lambda:InvokeFunction" Resource: !GetAtt "LambdaFunction.Arn" Effect: "Allow" 
+9
source

Source: https://habr.com/ru/post/1013084/


All Articles