Authorizer policy object losing attributes after parse
AWS expects the output of a policy object to look like this
{
"principalId": "user",
"policyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": "execute-api:Invoke",
"Effect": "Deny",
"Resource": "arn:aws:execute-api:us-west-2:123456789012:ymy8tbxw7b/*/GET/"
}
]
}
}
https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html
instead my policy object is returned like this
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "execute-api:Invoke",
"Effect": "Deny",
"Resource": "arn:aws:execute-api:us-west-2:123456789012:ymy8tbxw7b/*/GET/"
}
]
}
my generatePolicy return is formatted exactly like the desired object, when I test my custom authorizer over API Gateway -> Authorizers -> test , i even get the correct policy object BEFORE body parse, after body parse is when i lose my outer object with PrincipalId and PolicyDocument attributes
My Authorizers generatePolicy function
const generatePolicy = (principalId, effect, resource) => {
return {
principalId: principalId,
policyDocument: {
Version: '2012-10-17',
Statement: [
{
Action: 'execute-api:Invoke',
Effect: effect,
Resource: resource
}
]
},
//optional context
Context: {
stringKey: "value",
numberKey: "1",
booleanKey: "true"
}
}
In my protected endpoint the authroizer object never comes through with proxy under event.contextRequest.authorizer and in mapping template its not anywhere under context/request :/
Edit: sorry im a super dummy and posted this under java sdk , feel free to remove/close i will post under js
https://github.com/aws/aws-sdk-js/issues/2195