aws-amplify / aws-amplify/amplify-cli

add lambda trigger for auth post signup via `function add`

Open
#3,927 7 comments 17 reactions 0 assignees View on GitHub
auth feature-request p3
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

**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:
```bash
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:
```bash
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](https://aws.amazon.com/about-aws/whats-new/2019/07/amplify-framework-now-supports-adding-aws-lambda-triggers-for-events-auth-storage-categories/) and [here](https://aws.amazon.com/blogs/mobile/amplify-framework-adds-supports-for-aws-lambda-triggers-in-auth-and-storage-categories/), 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.