Repository: getmoto/moto
Issue: Invoke Lambda InvocationType RequestResponse not returning 200 HTTPStatusCode

AWS docs stating syncronous ResquestResponse should return a 200
https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html#API_Invoke_ResponseSyntax

https://github.com/spulec/moto/blob/8e2e3cec5a5b31ad4b81c24e087b4df6f1a2b279/tests/test_awslambda/test_lambda.py#L117

#2623 is focusing on the return value but also alluded to this discrepancy. 

Changed files:
moto/awslambda/responses.py, tests/test_awslambda/test_lambda.py

diff --git a/moto/awslambda/responses.py b/moto/awslambda/responses.py
index 46203c10d..d79336e23 100644
--- a/moto/awslambda/responses.py
+++ b/moto/awslambda/responses.py
@@ -172,7 +172,13 @@ class LambdaResponse(BaseResponse):
             function_name, qualifier, self.body, self.headers, response_headers
         )
         if payload:
-            return 202, response_headers, payload
+            if request.headers["X-Amz-Invocation-Type"] == "Event":
+                status_code = 202
+            elif request.headers["X-Amz-Invocation-Type"] == "DryRun":
+                status_code = 204
+            else:
+                status_code = 200
+            return status_code, response_headers, payload
         else:
             return 404, response_headers, "{}"
 
diff --git a/tests/test_awslambda/test_lambda.py b/tests/test_awslambda/test_lambda.py
index 2835729f8..4f587cdd8 100644
--- a/tests/test_awslambda/test_lambda.py
+++ b/tests/test_awslambda/test_lambda.py
@@ -113,7 +113,7 @@ def test_invoke_requestresponse_function():
         Payload=json.dumps(in_data),
     )
 
-    success_result["StatusCode"].should.equal(202)
+    success_result["StatusCode"].should.equal(200)
     result_obj = json.loads(
         base64.b64decode(success_result["LogResult"]).decode("utf-8")
     )
@@ -151,6 +151,34 @@ def test_invoke_event_function():
     json.loads(success_result["Payload"].read().decode("utf-8")).should.equal({})
 
 
+@mock_lambda
+def test_invoke_dryrun_function():
+    conn = boto3.client("lambda", _lambda_region)
+    conn.create_function(
+        FunctionName="testFunction",
+        Runtime="python2.7",
+        Role=get_role_name(),
+        Handler="lambda_function.lambda_handler",
+        Code={"ZipFile": get_test_zip_file1(),},
+        Description="test lambda function",
+        Timeout=3,
+        MemorySize=128,
+        Publish=True,
+    )
+
+    conn.invoke.when.called_with(
+        FunctionName="notAFunction", InvocationType="Event", Payload="{}"
+    ).should.throw(botocore.client.ClientError)
+
+    in_data = {"msg": "So long and thanks for all the fish"}
+    success_result = conn.invoke(
+        FunctionName="testFunction",
+        InvocationType="DryRun",
+        Payload=json.dumps(in_data),
+    )
+    success_result["StatusCode"].should.equal(204)
+
+
 if settings.TEST_SERVER_MODE:
 
     @mock_ec2
@@ -179,7 +207,7 @@ if settings.TEST_SERVER_MODE:
             InvocationType="RequestResponse",
             Payload=json.dumps(in_data),
         )
-        result["StatusCode"].should.equal(202)
+        result["StatusCode"].should.equal(200)
         actual_payload = json.loads(result["Payload"].read().decode("utf-8"))
         expected_payload = {"id": vol.id, "state": vol.state, "size": vol.size}
         actual_payload.should.equal(expected_payload)