aws-lambda

Debug dotnet core 2.0 AWS Lambda Functions in VS Code (C#)

筅森魡賤 提交于 2019-12-11 06:21:06
问题 I'm using VS Code to write Lambda functions using the dotnet core 2.0 CLI. VS Code v1.24.1 dotnet Core CLI v2.1.200 Problem I can't get the debugger to work locally with the function I've written in VS Code. I place a breakpoint on the line var body = request?.Body; (See Function.cs code block below). When I then click the start debugging button in the Debug tab in VS Code, I get the following: ------------------------------------------------------------------- You may only use the Microsoft

How to access header values in AWS lambda function

别说谁变了你拦得住时间么 提交于 2019-12-11 06:18:02
问题 I have created a Lambda authentication function in nodeJS and created an API gateway and called the function successfully by passing the parameters from body of the CURL. Code. var AWS = require('aws-sdk'); var lambda = new AWS.Lambda(); var RES; exports.handler = function(event,context,callback) { var userName=event.userName; var passWord=event.passWord; var params = { FunctionName: 'ServiceAuthentication', // the lambda function we are going to invoke InvocationType: 'RequestResponse',

convert from string to pandas dataframe

。_饼干妹妹 提交于 2019-12-11 06:11:55
问题 I'm importing a csv file from AWS S3 in AWS Lambdawith below code: file = s3.get_object(Bucket = bucket, Key = key) rows = file['Body'].read().decode('utf-8').splitlines(False) I'm getting input in below format : data = "a,b,c,d,\"x,y\",e,f" and I want output in below format: >>>`>>> df 0 1 2 3 4 5 6 0 a b c d x,y e f` i have to split data based on ',' but if some thong is between " " they should remain as it is. Or if you have any other solution for import csv file from s3 to lambda and

Writing a file to S3 using Lambda in Python with AWS

我只是一个虾纸丫 提交于 2019-12-11 06:07:38
问题 In AWS, I'm trying to save a file to S3 in Python using a Lambda function. While this works on my local computer, I am unable to get it to work in Lambda. I've been working on this problem for most of the day and would appreciate help. Thank you. def pdfToTable(PDFfilename, apiKey, fileExt, bucket, key): # parsing a PDF using an API fileData = (PDFfilename, open(PDFfilename, "rb")) files = {"f": fileData} postUrl = "https://pdftables.com/api?key={0}&format={1}".format(apiKey, fileExt)

How to use AWS Elasticache from Lambda in c#

给你一囗甜甜゛ 提交于 2019-12-11 05:55:58
问题 I've searched and searched and have been unable to find a tutorial / example / walkthrough with all of the above! I am trying to write a Lambda function in C# which makes use of some ElastiCache storage. I can find examples of ElastiCache access from C#, but every Library I have found referenced will not operate with .NetCore 1.0, which is what Lambda uses! Has anyone managed to do this? Many thanks. 回答1: Yes, it is possible and you're right, the information on this subject is sparse. The key

How do you call a function with parameters in a .then function in a JavaScript promise string?

喜你入骨 提交于 2019-12-11 05:51:58
问题 I am converting my AWS lambda functions, written in node.js, to use promises instead of callbacks. I'm wrapping all of my functions in the handler with the handler code. I'm trying to break out simple functions so I can have as flat a promise chain as possible in the handler code. I'm stuck at one point where I have a .then() that returns a value that I need to pass to one of my functions, which has been promisified, along with other parameters. I have searched high & low but can't find an

How to get validate Cognito Access Token in AWS Lambda to allow Gateway API call?

柔情痞子 提交于 2019-12-11 05:44:57
问题 What I am trying to do is to set up API Gateway to my Lambda function that saves some in DynamoDB (or other stuff that I want to be only for logged in users). But I do not understand how to validate AccessToken and how to get user from that. I found this post on AWS forum and I decided to try approach 1. Cognito User Pools + API Gateway + API Gateway Custom Authorizer + Cognito User Pools Access Token. So now I have logged in user : var authenticationData = { Username : 'username', // your

Kinesis lambda DynamoDB

ε祈祈猫儿з 提交于 2019-12-11 05:35:48
问题 I am learning the AWS services for a use case. After going through the docs I came came up with the a simple flow. I want to ingest data into the Kinesis streams by using the Streams API and the KPL. I use the example putRecord method to ingest data to the streams. I am ingesting the this JSON to the stream - {"userid":1234,"username":"jDoe","firstname":"John","lastname":"Doe"} Once the data is ingested i get the following response in putRecordResult - Put Result :{ShardId: shardId

How to run `AWS CLI` command within `aws lambda` function?

百般思念 提交于 2019-12-11 05:29:30
问题 I would like to run aws cli command (actually aws s3 sync) from within the aws lambda function . How do I do that? Ideally in python , but javascript (or java ) would work too. Using python I tried achieving this by Creating a Deployment Package where i would have awscli as a python package, so that I can use it later. However, the aws command is not available during lambda function execution, and only the awscli package is. How can I: either: make sure that I have awscli available to be

AWS Lambda stops working if it breaks once

耗尽温柔 提交于 2019-12-11 04:55:08
问题 I have a lambda with 5s timeout. Here is a simple lambda that I upload: exports.handle = function(event, context, callback) { if (Math.random() < 0.5) { callback(null, "done"); } else { setTimeout(() => callback(null, "delayed"), 6000); } }; As you can see, 50% of the times it should just return 'done' but the other 50% of the time, there should be a delay that is higher than the timeout and I expect to get a timeout error. Problem is, once I get the timeout error, I will ALWAYS get a timeout