aws-lambda

How to execute spark submit on amazon EMR from Lambda function?

强颜欢笑 提交于 2019-12-29 03:05:35
问题 I want to execute spark submit job on AWS EMR cluster based on the file upload event on S3. I am using AWS Lambda function to capture the event but I have no idea how to submit spark submit job on EMR cluster from Lambda function. Most of the answers that i searched talked about adding a step in the EMR cluster. But I do not know if I can add add any step to fire "spark submit --with args" in the added step. 回答1: You can, I had to same thing last week! Using boto3 for Python (other languages

Configure CORS response headers on AWS Lambda?

蓝咒 提交于 2019-12-29 01:32:43
问题 I'm trying to create a new service using AWS API Gateway, but I found out the browser automatically calls OPTIONS method in order to obtain CORS information. The problem is that AWS API Gateway does not offer a native way to configure CORS headers. Is it possible to create a Lambda Script in order to respond to OPTIONS method? 回答1: If you're using {proxy+} endpoint, you must handle CORS HTTP requests in the Lambda function. The implementation depends on the framework you're using. For Express

Return HTML from AWS API Gateway

社会主义新天地 提交于 2019-12-28 09:18:22
问题 I am trying to achieve the same thing as this post, but I do not understand the reply there and don't have permission to ask for clarification in the comments. I have an API Gateway endpoint that accepts a GET request, passes through some request variables to the Lambda function (implemented in Python), and returns text/html via an Empty Response Model (as described here As described in the earlier SO question, if the Lambda function returns an HTML string and the API endpoint uses the

how to read an excel file using node.js

久未见 提交于 2019-12-26 14:00:10
问题 I'm trying to read an excel file present in S3 using node.js integrated with lambda . I mean the code should interact with excel file and display the output. Please help me in this issue. 回答1: To read a file from S3 in AWS lambda with nodejs you can follow given steps. To read data from excel file in node js, I prefer xlsx package. To use it, first you need to install xlsx node package and then proceed as given - npm i xlsx --save Then you can read excel file as - const xlsx = require('xlsx')

What are the drawbacks of SQS poller which AWS Lambda removes?

时间秒杀一切 提交于 2019-12-25 18:54:07
问题 I have an architecture which looks like as follows:- Multiple SNS -> (AWS Lambda or SQS with Poller)??? -> Dynamo Db So, basically multiple SNS have subscribed to AWS Lambda or SQS with Poller and that thing pushes data to Dynamo Db. But this ? thing do lot of transformation of message in between. So, now for such case, I can either use AWS Lambda or SQS with Poller. With AWS Lambda, I can do transformation in Lambda function and with SQS with Poller, I can do transformation in Poller. With

AWS Lambda fs.readfile issue

随声附和 提交于 2019-12-25 18:38:47
问题 I'm packing some files in my lambda package that I need. I've used some example floating around to nearly get it working. I'm able to verify the path of a file OK const deviceCert = path.resolve(certType + "-deviceCert.key"); which logs out to "message": "Resolved path to TEST-deviceCert.key: /var/task/TEST-deviceCert.key" when I attempt to read the file using fs.readFile(deviceCert, (err, data) => { if (err) { log.error(`Verify deviceCert failure: ${err}`); responseBody = Helper

VPC-enabled Lambda function cannot launch/access EC2 in the same VPC

泄露秘密 提交于 2019-12-25 17:46:26
问题 I have a VPC enabled Lambda function which attempts to launch an EC2 using a launch template. The EC2 launch step (run_instances) fails with the below generic network error. Calling the invoke API action failed with this message: Network Error I can launch an instance successfully directly from the launch template, so I think everything is fine with the launch template. I have configured the following in the launch template Amazon Machine Image ID Instance type Key Pair A network interface

Can we write an AWS Lambda function to query Kinesis Streams

你说的曾经没有我的故事 提交于 2019-12-25 17:16:37
问题 I have Amazon Kinesis Streams, which has all the click stream data and we want to write an API to query Kinesis Streams. My plan is to create a API gateway which calls an AWS Lambda function that would query Kinesis Streams and return it back. Is it possible to use Lambda to query Kinesis Streams or should we use Kinesis Analytics and Lambda? 回答1: You can use AWS Kinesis with Lambda via the Stream-based model. AWS Lambda will itself poll the kinesis stream and fetch the number of records

How to store mongodb output in variable using nodejs in lambda function?

做~自己de王妃 提交于 2019-12-25 17:04:25
问题 In a lambda function, I have the following code: var user; exports.handler = function uploadToS3(event, context, callback) { var name = event["username"]; MongoClient.connect(uri, { useNewUrlParser: true }, (error, client) => { if (error) return 1; // Checking the connection db = client.db(databasename); db.collection("user_profile").findOne({ username: name }, function( err, result ) { if (err) throw err; user = result._id; console.log(user); // 1st console.log }); }); console.log(user); /

How do you run RServe on AWS Lambda with NodeJS?

时光毁灭记忆、已成空白 提交于 2019-12-25 12:08:15
问题 While this question is quite open-ended, I'm generally trying to follow this excellent post here: https://aws.amazon.com/blogs/compute/analyzing-genomics-data-at-scale-using-r-aws-lambda-and-amazon-api-gateway/ which describes setting up R to run with python. I, on the other hand, am trying to get R to work with NodeJs. I've packaged up my dependencies, deployed to Lambda, and can run simple Node scripts. However, I am having difficulty connecting to RServe from Node using the npm package Rio