Event.methodArn is undefined on API Gateway Lambda authorizers

Viewed 744

I'm using a Lambda function to control access to my API Gateway. The function event.methodArn is undefined and I don't why. Any ideia what's wrong?

Let me know if you need any other information

Authorizer configuration

enter image description here

Lambda function

exports.handler = (event, context, callback) => {
    
    const token = event.authorizationToken;
    console.log("event.methodArn " + event.methodArn);
    // Use token
    if(token === "allow"){
        const policy = genPolicy("allow", event.methodArn);
        const principalId = "hus8r238sh1";
        const context = {
            simpleAuth: true
        };
        
        const response = {
            principalId: principalId,
            policyDocument: policy,
            context: context
        };
        
        callback(null, response);
    }else if(token === "deny"){
        const policy = genPolicy("deny", event.methodArn);
        const principalId = "hus8r238sh1";
        const context = {
            simpleAuth: true
        };
        
        const response = {
            principalId: principalId,
            policyDocument: policy,
            context: context
        };
        
        callback(null, response);
    }else{
        callback(null, "Unauthorized");
    }
    
    
};

function genPolicy(effect, resource){
    const policy = {};
    policy.Version = "2020-12-08";
    policy.Statement = [];
    const stmt = {};

    stmt.Action = "execute-api:Invoke";
    stmt.Effect = effect;
    stmt.Resource = resource;
    policy.Statement.push(stmt);
    
    return policy;
    
}

Log

2020-12-08T23:18:46.256Z    53b3461f-5f6a-4ddd-9000-53b93752449a    INFO    event.methodArn undefined
0 Answers
Related