diff --git a/cloud/aws/runtime/gateway/lambda.go b/cloud/aws/runtime/gateway/lambda.go index 5dc9fcc7c..7a8d39b98 100644 --- a/cloud/aws/runtime/gateway/lambda.go +++ b/cloud/aws/runtime/gateway/lambda.go @@ -181,8 +181,20 @@ func (s *LambdaGateway) handleApiEvent(ctx context.Context, evt events.APIGatewa } } + data := []byte(evt.Body) + if evt.IsBase64Encoded { + data, err = base64.StdEncoding.DecodeString(evt.Body) + if err != nil { + return events.APIGatewayProxyResponse{ + StatusCode: 400, + Body: "Error processing lambda request", + IsBase64Encoded: false, + }, nil + } + } + req := &v1.TriggerRequest{ - Data: []byte(evt.Body), + Data: data, Context: &v1.TriggerRequest_Http{ Http: &v1.HttpTriggerContext{ Method: evt.RequestContext.HTTP.Method, @@ -220,10 +232,9 @@ func (s *LambdaGateway) handleApiEvent(ctx context.Context, evt events.APIGatewa responseString := base64.StdEncoding.EncodeToString(response.Data) return events.APIGatewayProxyResponse{ - StatusCode: int(response.GetHttp().Status), - Headers: lambdaHTTPHeaders, - Body: responseString, - // TODO: Need to determine best case when to use this... + StatusCode: int(response.GetHttp().Status), + Headers: lambdaHTTPHeaders, + Body: responseString, IsBase64Encoded: true, }, nil }