Lambda trigger cannot access other lambda functions
Before opening, please confirm:
- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have searched for duplicate or closed issues.
- [X] I have read the guide for submitting bug reports.
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
How did you install the Amplify CLI?
yarn
If applicable, what version of Node.js are you using?
v16.14.2
Amplify CLI Version
9.1.0
What operating system are you using?
Mac
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No manual changes made
Amplify Categories
function
Amplify Commands
add
Describe the bug
The new lambda trigger for dynamodb, cannot access other lambda functions (or dynamo tables).
Expected behavior
The lambda trigger should get the response from the callee lambda.
Reproduction steps
- create a new, clean amplify project
- add graphql API. I am using the one-to-many example

- create a function to be called (testCallee)

- add the lambda trigger

- update the function

- the output log (from test event)

The problem is the await lambda.invoke(params).promise() line not working. There should be some erorrs or reponses, but it seems the thread is killed silently.
GraphQL schema(s)
# Put schemas below this line
# This "input" configures a global authorization rule to enable public access to
# all models in this schema. Learn more about authorization rules here: https://docs.amplify.aws/cli/graphql/authorization-rules
input AMPLIFY {
globalAuthRule: AuthRule = { allow: public }
} # FOR TESTING ONLY!
type Blog @model {
id: ID!
name: String!
posts: [Post] @hasMany
}
type Post @model {
id: ID!
title: String!
blog: Blog @belongsTo
comments: [Comment] @hasMany
}
type Comment @model {
id: ID!
post: Post @belongsTo
content: String!
}
Project Identifier
➜ testTrigger amplify diagnose --send-report
Learn more at https://docs.amplify.aws/cli/reference/diagnose/
✅ Report saved: /var/folders/2j/4v3x_j4x7x509ghkl7dwcps80000gp/T/testTrigger/report-1662357560078.zip
✔ Done
Project Identifier: f5a3b30854f88a8b2a2549e91d848f02
Log output
# Put your logs below this line
Additional information
No response
Hey @nxia416 :wave: thanks for raising this! I noticed you're using async with Array.forEach, which unfortunately is likely the cause of what you're seeing. If you migrate this to use for..of does it function as expected?
for (const record of event.Records) {
// ...
await invoke(params)
}
For reference here is a short gist I found that explains this issue with async/await and forEach in more detail: https://gist.github.com/joeytwiddle/37d2085425c049629b80956d3c618971