使用 amozon cognito 在无服务器设置中找到对 dynamodb table 的粒度访问控制

find grained access control to a dynamodb table in a serverless setup with amozon cognito

我有一组用户通过 amazon cognito 进行身份验证。

现在,使用 dynamodb、api 网关和 lambda,我想创建一个数据库,其中每个条目:

我想创建一个设置,其中:

那我该怎么做呢? 据我所知,我无法在 aws lambda 中获取 cognito 用户名。

是否可以使用不带任何 lambda 函数的 api 网关代理?[​​=11=]

您可以通过 API 网关将 Cognito 用户池用户名传递给 Lambda 函数。大体上,您需要遵循的步骤是。

1. SignUp and SignIn with Cognito user pools.
2. Use the access token to invoke a API gateway endpoint using [custom authorizes](https://mobile.awsblog.com/post/Tx3JK25U7Z9EUIU/Integrating-Amazon-Cognito-User-Pools-with-API-Gateway).
3. Trigger the lambda function from API gateway and pass the user name in context.

查看此 forum post 了解更多详情。