Is your feature request related to a problem? Please describe.
I'd like to insert a new record into a user collection when a user confirms signup. This seems like a trivial thing. It's not. Since GraphQL mutations can be observed, I'd like to use the API (from the triggler lambda) to insert the record.
It seems impossible to add a trigger for auth post-confirm events that can invoke the API.
The closest I've come is:
amplify auth add
...
amplify api add
...
amplify auth update
...choose crazy options to let me setup a trigger
...MISSING ABILITY TO DEFINE PERMISSIONS TO ACCESS API RESOURCE
With this flow, I am blocked as I cannot get access to the API resource injected into my lambda code.
Also, I don't love the name chosen for the lambda resource. It seems based on the poorly chosen name for the auth resource.
Describe the solution you'd like
I expect the following flow to work:
amplify auth add
...
amplify api add
...
amplify function add
...
? What event source do you want to associate with Lambda trigger? (Use arrow keys)
❯ Amazon DynamoDB Stream
Amazon Kinesis Stream
Amazon Cognito User Pool Post Confirm // CURRENTLY MISSING
...
...choose permissions to access API resource
...
# no longer needed - amplify auth update
Describe alternatives you've considered
Already mentioned above.
Additional context
Has anyone used the lambda trigger feature? It's touted here and here, but it's really difficult to setup.
I mean, how do you even start the mentioned "manual Auth CLI workflow"? It's really buried under "amplify auth update".
https://aws-amplify.github.io/docs/cli-toolchain/quickstart#adding-a-lambda-trigger
...and I just learned that the code generated has no file named index.js which is expected by the deployment and runtime errors occur because it is missing. Instead custom.js has the .handler entry point.
🐛 BUG
+1. Any update on this? I want to add a "Migrate User Lambda Trigger" but the new documentation does not mention how to add triggers at all: https://docs.amplify.aws/cli/auth/overview
I have a new plan for solving this. I think you can use the CLI to scaffold a basic function resource, and then manually enhance the generated cloudformation template.
There is a pretty nice DSL for passing parameters around, and you can hack the cloudformation template to accept and use these parameters. For an example injecting parameters, see
https://github.com/aws-amplify/amplify-cli/issues/3240#issuecomment-623499312
Noticed this issue after I opened a related one, so linking it: https://github.com/aws-amplify/amplify-cli/issues/4326
Most helpful comment
Noticed this issue after I opened a related one, so linking it: https://github.com/aws-amplify/amplify-cli/issues/4326