working with api gateway, lambda and cognito

0

i have an PYTHON lambda api and now i want to add authentication system beucase i want my users register and pay for my service. i know i can adapt cognito directly to api gateway but i want some changes.

1- i want my users can use my serves for a while(request count) 2- then i want to forward my users to authentication lambda to register and payment (it is another lambda function than my api) 3- i want to hold payment status and date on my user pool to track payment status

i can just use cognito boto3 sdk by my authentication lambda but i am not able to adapt it my main lambda api. you can share to me documents

thanks

3 個答案
0
已接受的答案

Based on my understanding of your question. you have two types of users

  1. Guest users (unauthenticated) - these users can access some of your services.
  2. Authenticated users - you need the user to authenticate before they pay for your services.

Cognito provide both unauthenticated and authenticated users. Moreover , Cognito can also switch the unauthenticated users to authenticated users with the same unique identifier. please check this for more details - https://docs.aws.amazon.com/cognito/latest/developerguide/switching-identities.html.

I would recommend to use Dynamo DB for payment status , you can use user unique id in Dynamo DB to map it with the users in user pool.

AWS
已回答 1 年前
  • thanks. but i think i can hold payment status on cognito user pool. i will try it this later because i am in the beginning of the development. by the way i have an rds but also can hold a dynamodb for payment status

  • While you can have ways to store payment status in user pool but as a best practice you should keep payment information separate from user information. This helps to scale your application better.

0

Hi,

Have a read at this: https://repost.aws/knowledge-center/api-gateway-cognito-user-pool-authorizer as it covers and links to official guides about setting it up.

Finally this is more a comprehensive guide with tutorials and hands on workshops. https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-tutorials.html

Hope it helps ;)

profile picture
專家
已回答 1 年前
0

API Gateway and Cognito do not provide a way for doing what you want. Further more, as you want to be able to give your uses some number of free APIs, you need to know who they are.

I would recommend that you use Cognito for user registration and authentication, API Gateway for enforcing the credentials and the Lambda function to implement the business logic, that will include also counting calls and saving the information to Dynamo DB, which then can be used for charging.

profile pictureAWS
專家
Uri
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南