title: Pass request body parameters from API Gateway to Lambda using Terraform to create them
body: <p>I am trying to create a AWS gateway API attached to a Lambda function. I have written the script and I am able to execute the script. On calling the API Gateway the request body passed to the API gateway is not being passed to the lambda function.</p>
  <p>Below is the terraform code for API Gateway</p>
  <pre><code># API gateway
  resource &quot;aws_apigatewayv2_api&quot; &quot;lambda-gw&quot; {
    name          = &quot;lambda-gw&quot;
    protocol_type = &quot;HTTP&quot;
  }
  
  resource &quot;aws_apigatewayv2_stage&quot; &quot;lambda-gw&quot; {
    api_id = aws_apigatewayv2_api.lambda-gw.id
  
    name        = &quot;Production&quot;
    auto_deploy = true
  
    access_log_settings {
      destination_arn = aws_cloudwatch_log_group.api_gw.arn
  
      format = jsonencode({
        requestId               = &quot;$context.requestId&quot;
        sourceIp                = &quot;$context.identity.sourceIp&quot;
        requestTime             = &quot;$context.requestTime&quot;
        protocol                = &quot;$context.protocol&quot;
        httpMethod              = &quot;$context.httpMethod&quot;
        resourcePath            = &quot;$context.resourcePath&quot;
        routeKey                = &quot;$context.routeKey&quot;
        status                  = &quot;$context.status&quot;
        responseLength          = &quot;$context.responseLength&quot;
        integrationErrorMessage = &quot;$context.integrationErrorMessage&quot;
        }
      )
    }
  }
  
  resource &quot;aws_apigatewayv2_integration&quot; &quot;lambda-gw&quot; {
    api_id = aws_apigatewayv2_api.lambda-gw.id
  
    integration_uri    = aws_lambda_function.update_shadow.invoke_arn
    integration_type   = &quot;AWS_PROXY&quot;
    integration_method = &quot;POST&quot;
  }
  
  resource &quot;aws_apigatewayv2_route&quot; &quot;lambda&quot; {
    api_id = aws_apigatewayv2_api.lambda-gw.id
  
    route_key = &quot;POST /lambda&quot;
    target    = &quot;integrations/${aws_apigatewayv2_integration.lambda-gw.id}&quot;
  }
  
  resource &quot;aws_cloudwatch_log_group&quot; &quot;api_gw&quot; {
    name = &quot;/aws/api_gw/${aws_apigatewayv2_api.lambda-gw.name}&quot;
  
    retention_in_days = 30
  }
  
  resource &quot;aws_lambda_permission&quot; &quot;api_gw&quot; {
    statement_id  = &quot;AllowExecutionFromAPIGateway&quot;
    action        = &quot;lambda:InvokeFunction&quot;
    function_name = aws_lambda_function.update_shadow.function_name
    principal     = &quot;apigateway.amazonaws.com&quot;
  
    source_arn = &quot;${aws_apigatewayv2_api.lambda-gw.execution_arn}/*/*&quot;
  }
  </code></pre>
  <p>Error on Lambda
  <a href="https://i.stack.imgur.com/zfoOA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zfoOA.png" alt="enter image description here" /></a></p>
  <p>In the lambda event I am getting the entire request including headers, request context, body etc. I need only the body to be passed across</p>