I have several AWS lambdas running, supported by the Serverless Framework. I need one lambda (called lambdaOne) which will call a second lambda (called lambdaTwo) using AWS' javascript sdk. The issue is that I am getting an AccessDenied Exception when I attempt this:
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): AccessDeniedException: User: arn:aws:sts::12345678909876:assumed-role/test-dev-us-west-2-lambdaRole/test-dev-lambdaOne is not authorized to perform: lambda:Invoke Function on resource: arn:aws:lambda:us-west-2:994979977450:function:test-dev-lambdaTwo
To my understanding, Serverless creates a default IAM role for all lambda functions. So, I should be able to just to add a new entry under iamRoleStatements.
My confusion arises from the fact that the resource I want to reference (lambdaTwo) is already defined as a function.
Is there a way to reference a function as a resource?