Created
June 20, 2020 17:55
-
-
Save DanielDaCosta/5228ce5447dc47509d739c1acd7be49d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| resource "aws_api_gateway_integration" "api" { | |
| rest_api_id = aws_api_gateway_rest_api.apiGateway.id | |
| resource_id = aws_api_gateway_resource.form_score.id | |
| http_method = aws_api_gateway_method.method_form_score.http_method | |
| type = "AWS" | |
| integration_http_method = "POST" | |
| credentials = aws_iam_role.apiSQS.arn | |
| uri = "arn:aws:apigateway:${var.region}:sqs:path/${aws_sqs_queue.queue.name}" | |
| request_parameters = { | |
| "integration.request.header.Content-Type" = "'application/x-www-form-urlencoded'" | |
| } | |
| # Request Template for passing Method, Body, QueryParameters and PathParams to SQS messages | |
| request_templates = { | |
| "application/json" = <<EOF | |
| Action=SendMessage&MessageBody={ | |
| "method": "$context.httpMethod", | |
| "body-json" : $input.json('$'), | |
| "queryParams": { | |
| #foreach($param in $input.params().querystring.keySet()) | |
| "$param": "$util.escapeJavaScript($input.params().querystring.get($param))" #if($foreach.hasNext),#end | |
| #end | |
| }, | |
| "pathParams": { | |
| #foreach($param in $input.params().path.keySet()) | |
| "$param": "$util.escapeJavaScript($input.params().path.get($param))" #if($foreach.hasNext),#end | |
| #end | |
| } | |
| }" | |
| EOF | |
| } | |
| depends_on = [ | |
| aws_iam_role_policy_attachment.api_exec_role | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment