I have an AWS Lambda function in Node.js that uses the SDK method listVersionsByFunction.
It's created from this AWS SAM template:
AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Globals: Function: Timeout: 3 Resources: special: Type: AWS::Serverless::Function Properties: FunctionName: 'my-project-special' CodeUri: ./handlers Handler: special.handler Runtime: nodejs10.x getLatest: Type: AWS::Serverless::Function Properties: CodeUri: ./handlers Handler: getLatest.handler Runtime: nodejs10.x Events: getLatest: Type: Api Properties: Path: /latest/ Method: get and the handler calls the SDK like this:
const result = await lambda.listVersionsByFunction({ FunctionName: 'my-project-special', }).promise(); After deploying and making a request, there's an AccessDeniedException error:
User: arn:aws:sts::999999999:assumed-role/my-project-getLatest-ADFADSFASD/my-project-getLatest-HJLKHLKJKJ is not authorized to perform: lambda:ListVersionsByFunction on resource: arn:aws:lambda:us-east-2:999999999:function:my-project-special
How can I allow this access by means of the AWS SAM template?
