AWS API Gateway REST Lambda Integration Payloads
I couldn’t find these specific payload examples anywhere, AWS docs only have a generic example. So I got it through empirical means.
Tip
In lines like
"user": "AIDA2CRXO3S2JFSU7S42X"
or "AROA2DREO3S2A6XFQAO5U:john.doe"
the value is not an access key id, but an IAM user id.IAM user calling APIGW REST Lambda integration with IAM authentication enabled:
{
"resource": "/example-path",
"path": "/example-path",
"httpMethod": "POST",
"headers": null,
"multiValueHeaders": null,
"queryStringParameters": null,
"multiValueQueryStringParameters": null,
"pathParameters": null,
"stageVariables": null,
"requestContext": {
"resourceId": "mg6x8l",
"resourcePath": "/example-path",
"httpMethod": "POST",
"extendedRequestId": "HiNnXXJkoAGF3fQ=",
"requestTime": "04/Jul/2023:10:36:30 +0000",
"path": "/example-path",
"accountId": "111122223333",
"protocol": "HTTP/1.1",
"stage": "test-invoke-stage",
"domainPrefix": "testPrefix",
"requestTimeEpoch": 1688466990816,
"requestId": "efbo9bdf-2b28-4ad7-8ed2-2311f812ea0f",
"identity": {
"cognitoIdentityPoolId": null,
"cognitoIdentityId": null,
"apiKey": "test-invoke-api-key",
"principalOrgId": null,
"cognitoAuthenticationType": null,
"userArn": "arn:aws:iam::111122223333:user/john.doe",
"apiKeyId": "test-invoke-api-key-id",
"userAgent": "aws-cli/2.12.3 Python/3.11.4 Darwin/22.3.0 source/x86_64 prompt/off command/apigateway.test-invoke-method",
"accountId": "111122223333",
"caller": "AIDA2CRXO3S2JFSU7S42X",
"sourceIp": "test-invoke-source-ip",
"accessKey": "AKIA2ADEO2S3EC6SXAEF",
"cognitoAuthenticationProvider": null,
"user": "AIDA2CRXO3S2JFSU7S42X"
},
"domainName": "testPrefix.testDomainName",
"apiId": "rx6oc8kb6k"
},
"body": null,
"isBase64Encoded": false
}
Assumed IAM role user calling APIGW REST Lambda integration with IAM authentication enabled:
{
"resource": "/example-path",
"path": "/example-path",
"httpMethod": "POST",
"headers": null,
"multiValueHeaders": null,
"queryStringParameters": null,
"multiValueQueryStringParameters": null,
"pathParameters": null,
"stageVariables": null,
"requestContext": {
"resourceId": "mg6x8l",
"resourcePath": "/example-path",
"httpMethod": "POST",
"extendedRequestId": "HiOQcH2HoAMFxGw=",
"requestTime": "04/Jul/2023:10:40:53 +0000",
"path": "/example-path",
"accountId": "111122223333",
"protocol": "HTTP/1.1",
"stage": "test-invoke-stage",
"domainPrefix": "testPrefix",
"requestTimeEpoch": 1688467253894,
"requestId": "78bh889a-8077-453a-92c1-a2e83dd34767",
"identity": {
"cognitoIdentityPoolId": null,
"cognitoIdentityId": null,
"apiKey": "test-invoke-api-key",
"principalOrgId": null,
"cognitoAuthenticationType": null,
"userArn": "arn:aws:sts::111122223333:assumed-role/AWSReservedSSO_Admins_b7d0fbf1e66ed829/john.doe",
"apiKeyId": "test-invoke-api-key-id",
"userAgent": "aws-cli/2.12.3 Python/3.11.4 Darwin/22.3.0 source/x86_64 prompt/off command/apigateway.test-invoke-method",
"accountId": "111122223333",
"caller": "AROA2DREO3S2A6XFQAO5U:john.doe",
"sourceIp": "test-invoke-source-ip",
"accessKey": "ASIA2WRSO2X2AV62H59B",
"cognitoAuthenticationProvider": null,
"user": "AROA2DREO3S2A6XFQAO5U:john.doe"
},
"domainName": "testPrefix.testDomainName",
"apiId": "rx6oc8kb6k"
},
"body": null,
"isBase64Encoded": false
}