Amplify-cli: Invoking a lambda from another Lambda

Created on 5 Jan 2019  路  3Comments  路  Source: aws-amplify/amplify-cli

* Which Category is your question related to? *
Functions
* What AWS Services are you utilizing? *
Lambda (and others - but not relevant to this question)
* Provide additional details e.g. code snippets *
I'm using AWS Amplify CLI Multienv 20, I'd like to be able to invoke another (Amplify managed) lambda function from my Amplify managed lambda function - I need to grant the invoking lambda the role that permits it to invoke my second lambda - however I cannot find any way to manage this with amplify?

If I edited the CFT, it could get over-written and it would be different between environments? Any advice, or is this not a feature available?

question

All 3 comments

@ReidWeb I beleive the CFT template won't get modified for the Lambda function. You can go ahead and modify it in the amplify/backend directory.

Ah that's good to know! Managed to add a segment to the lambda policy that'll allow me to invoke the secondary lambda

{  
   "Effect":"Allow",
   "Action":"lambda:InvokeFunction",
   "Resource":{  
      "Fn::Sub":[  
         "arn:aws:lambda:${region}:${account}:function:funcName-${env}",
         {  
            "region":{  
               "Ref":"AWS::Region"
            },
            "account":{  
               "Ref":"AWS::AccountId"
            },
            "lambda":{  
               "Ref":"LambdaFunction"
            },
            "env":{  
               "Ref":"env"
            }
         }
      ]
   }
}

so 馃it should work across environments - I'll reopen this if I face issues when promoting

Thanks @ReidWeb , That little code worked for me! In my case, I'm trying to execute another lambda through the post-confirmation lambda, because I have this issue: https://stackoverflow.com/questions/62503523/trying-to-use-model-within-post-confirmation-function

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kstro21 picture kstro21  路  3Comments

rehos picture rehos  路  3Comments

onlybakam picture onlybakam  路  3Comments

nicksmithr picture nicksmithr  路  3Comments

amlcodes picture amlcodes  路  3Comments