aws / aws/aws-lambda-go

Handler events.APIGatewayProxyRequest Cognito fields empty

Open
#133 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
Go
Stars
3.8k
Forks
578
Avg merge
8h 18m
Merged PRs (30d)
1

Description

I've deployed an API Gateway that calls a lambda_proxy handler. My handler function receives in a context and an `events.APIGatewayProxyRequest`. Inside the request, there are fields for the Cognito Identity ID and Pool ID, but both are empty. This may be related to Issue #106. While I saw a workaround to manually verify JWTs, that would seem to largely defeat the purpose of API Gateway Cognito authentication and certainly the request's cognito fields.

Code to reproduce the error:
```go
package main

func Handler(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
lc, _ := lambdacontext.FromContext(ctx)

fmt.Println("Context cognito identity id:", lc.Identity.CognitoIdentityID)
fmt.Println("Context Cognito pool:", lc.Identity.CognitoIdentityPoolID)
fmt.Println("Request context cognito id:", request.RequestContext.Identity.CognitoIdentityID)

return events.APIGatewayProxyResponse{}, nil
}

func main() {
lambda.Start(Handler)
}
```

I also dug into the aws-lambda-go/lambda/function.go Invoke() function and verified that the req.CognitoIdentityID and req.CognitoIdentityPoolId are both empty strings. I verified this using a deployed Lambda function that I tested using API Gateway and Postman (with valid JWT Cognito tokens) using Printlns also in the function.go Invoke() function.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.