Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible/safe to call AWS Lambda function directly from frontend?

I have Lambda function that executes in minimum 12 seconds so I can't expose it via AWS API Gateway (because of 10 sec timeout). What I was thinking is to call/execute Lambda function directly from frontend through AWS javascript SDK. Is it safe to create IAM user that will have only permission to execute this one particular function and hardcode this user AWS_KEY_ID and AWS_SECRET_KEY in frontend?

like image 531
user606521 Avatar asked Sep 24 '15 20:09

user606521


2 Answers

Yes it is possible. New AWS Service Cognito allows you to provide AWS creds specific to the end user. You can use those creds to access different aws services like DynamoDB or in your case AWS Lambda.

Is it safe to create IAM user that will have only permission to execute this one particular function and hardcode this user AWS_KEY_ID and AWS_SECRET_KEY in frontend?

Never do do this. Use AWS Service Cognito instead.

like image 125
Vor Avatar answered Nov 15 '22 18:11

Vor


You can use Amazon Gateway API's to connect from so called "front end" to lambda, checkout this tutorial from amazon.

like image 38
TheZuck Avatar answered Nov 15 '22 17:11

TheZuck