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 Answers
0
Accepted Answer

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
answered a year ago
  • 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
EXPERT
answered a year ago
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
EXPERT
Uri
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions