aws-lambda

Using AWS Lambda with Cognito and API Gateway

我们两清 提交于 2020-01-07 04:29:09
问题 How to get user in Lambda function? User is authenticated in Cognito and invokes lambda with API Gateway. API Gateway method has AWS_IAM authorizer and checked "Use Lambda Proxy integration" checkbox 回答1: If you have checked AWS_IAM API Gateway, identity of the end user available to your function. You can access the Identity ID as follows. exports.handler = function(event, context) { var identity = event.requestContext.identity.cognitoIdentityId; console.log("clientID = " + identity); context

Cannot call aws API Gateway via ajax

烂漫一生 提交于 2020-01-07 04:24:09
问题 I am using aws APi gateway and api gateway custom authorizer. The code that I have for api gateway custom authorizer is as follows: console.log('Loading function'); exports.handler = (event, context, callback) => { var token = event.authorizationToken; // Call oauth provider, crack jwt token, etc. // In this example, the token is treated as the status for simplicity. switch (token.toLowerCase()) { case 'allow': callback(null, generatePolicy('user', 'Allow', event.methodArn)); break; case

AWS Lambda questions

偶尔善良 提交于 2020-01-06 19:52:13
问题 I am using AWS Lambda as a backend - however I cannot figure out how to interact with my SQL database on Amazon RDS. I would simply like to be able to write API function inLambda to access and retrieve information from the database. To do this in python i would normally use the 'MySQLdb' module - however Lambda does not have this. Any suggestions? 回答1: If you you want to use external libraries, you need to create a deployment package that contains them and upload it via AWS console or S3.

Using Amazon Lex's inputTranscript to allow for an wide open slot

☆樱花仙子☆ 提交于 2020-01-06 12:36:22
问题 Can anyone provide any insight on exactly how to use the inputTranscript lex event to feed that input back to a slot as its value, to allow for an open slot type? I can capture the user input no problem, its just sending it back as the slot value where I'm encountering issues. From what I can see from researching, this is the best way to accomplish the ability to accept any value into a slot. I just cant seem to be able to actually get it to work. I've read a few posts stating to create the

Adding S3 trigger to Lambda function using CloudFormation

若如初见. 提交于 2020-01-06 09:03:13
问题 I'm trying to add an S3 trigger to a lambda function using CloudFormation. From what I've read about circular references the lambda function and S3 bucket needs to be created first, which I've done with a template and they get created successfully. Then I go into "Update Stack" and enter the template: "Resources": { "MyBucket": { "Type": "AWS::S3::Bucket", "NotificationConfiguration": { "LambdaConfigurations": [ { "Event": "s3:ObjectCreated:*", "Function": "arn:aws:lambda:ap-southeast-2

Validate Cognito session in Lambda function

喜你入骨 提交于 2020-01-06 07:30:48
问题 I have some data stored in DynamoDB. In order to retrieve the data, I'm requiring users to be authenticated against Cognito user pool. I have managed to authenticate users successfully using AWS-Amplify library and Cognito returns following JSON data after successful authentication : { "username":"....", "pool":{ "userPoolId":"....", "clientId":"...", "client":{ "endpoint":"....", "userAgent":"aws-amplify/0.1.x js" }, "advancedSecurityDataCollectionFlag":true, "storage":{ "loglevel:webpack

ASP.NET Core 2.1 reflection doesn't work when deploying in AWS lambda

放肆的年华 提交于 2020-01-06 07:21:12
问题 I have a library with the below code for dependency injection. This loads all implementation classes ending with Handler and register them. public static class HandlerRegistrationExtension { private static IDictionary<Type, Type> _decoratorsAttributes; public static void AddHandlers(this IServiceCollection services, IDictionary<Type, Type> decoratorsAttributes) { _decoratorsAttributes = decoratorsAttributes ?? new Dictionary<Type, Type>(); List<Type> allAssembliesTypes = Assembly

Error Updating Stack to Add S3 Trigger

故事扮演 提交于 2020-01-06 07:20:41
问题 I successfully created a lambda function and S3 bucket using a cloudformation stack. I then ran an update to the stack to add a trigger to the S3 bucket to invoke a lambda function. When I run the update it's giving the following error: Unable to validate the following destination configurations (Service: Amazon S3; Status Code: 400; Error Code: InvalidArgument; Request ID: XXXXX; S3 Extended Request ID: XXXXX This is the update JSON I'm using to add the trigger to the S3 bucket: "MyBucket":

Amazon Lex Timing out in 30 seconds on Lambda Fullfilment

孤者浪人 提交于 2020-01-06 06:46:49
问题 I have a lambda function which is tied to some external automation via a webservice. It takes about 45 seconds for the task to be completed. I have already updated the time limitation for the lambda call to 2 mins and when I am testing it works fine. However, when I am using the text bot in Amazon Lex I get the following message: An error has occurred: Invalid Bot Configuration: Lambda request did not complete within permissible time (30 seconds). Anyone know how to increase the Lex Bot

How to combined two output in lambda function using mongodb?

时光总嘲笑我的痴心妄想 提交于 2020-01-06 06:38:43
问题 I have two collection 1) profile ,2) posts find the below pic for your reference. user_prfoile collection user_posts collection In the lambda function, when i passed the userid, then we will get the userid revlevant data display. but i need user details in feelings array. I tried with the below code, but i get the empty output def lambda_handler(event, context): print("Received event: " + json.dumps(event, indent=1)) Userid = event['userid'] uid = ObjectId(Userid) dispost = list( db.user