aws-lambda

How to pass script to UserData field in EC2 creation on AWS Lambda?

人盡茶涼 提交于 2019-12-10 20:35:39
问题 I'm trying to pass a script in Userdata field of a new EC2 instance created by an AWS Lambda (using AWS SDK for Javascript, Node.js 6.10): ... var paramsEC2 = { ImageId: 'ami-28c90151', InstanceType: 't1.micro', KeyName: 'myawesomekwy', MinCount: 1, MaxCount: 1, SecurityGroups: [groupname], UserData:'#!/bin/sh \n echo "Hello Lambda"' }; // Create the instance ec2.runInstances(paramsEC2, function(err, data) { if (err) { console.log("Could not create instance", err); return; } var instanceId =

AWS API Gateway Custom Authorizer with Proxy setup - Add Custom Headers to Request

折月煮酒 提交于 2019-12-10 20:21:33
问题 What I have: AWS API gateway setup as a proxy (/{proxy+}) A custom Auth function which authorizes the incoming request for this proxy setup. The custom auth function is passing the additional information I want to pass along to the request via the "context" object, like so: { "principalId": "yyyyyyyy", "policyDocument": { "Version": "2012-10-17", "Statement": [ { "Action": "execute-api:Invoke", "Effect": "Allow|Deny", "Resource": "some arn" } ] }, "context": { "customInfo1": "hello",

Node.js: Download file from s3 and unzip it to a string

吃可爱长大的小学妹 提交于 2019-12-10 20:14:12
问题 I am writing an AWS Lambda function which needs to download files from AWS S3, unzips the file and returns the content in the form of a string. I am trying this function getObject(key){ var params = { Bucket: "my-bucket", Key: key } return new Promise(function (resolve, reject){ s3.getObject(params, function (err, data){ if(err){ reject(err); } resolve(zlib.unzipSync(data.Body)) }) }) } But getting the error Error: incorrect header check at Zlib._handle.onerror (zlib.js:363:17) at Unzip.Zlib.

How can I use axios in lambda?

岁酱吖の 提交于 2019-12-10 19:16:02
问题 Do I have to install the axios module locally and then deploy it to lambda or is there a way to do it through the inline code editor as well in the browser? 回答1: Lambda doesn't actually bundle your package dependencies for you, except the AWS package, so yes you'd need to install it locally, zip it together and upload to the Lambda console. 回答2: In the folder where your lambda script is present (index.js) run following command - npm install axios You should see node_modules directory getting

POST Request Not Recognizing Headers

女生的网名这么多〃 提交于 2019-12-10 18:54:59
问题 I am trying to make a POST request to an AWS Lambda Python Script I have set up. I have already heard about solving the issue of Access-Control-Allow-Origin by adding a header to the Response from AWS lambda, that looks like Access-Control-Allow-Origin:* , and I implemented this in the code I was working on for the get request. Then when I begun creating a POST request, I did the same thing, so that the new POST request originally looked like this: def post(event, context): try: return dict(

AWS lambda java response does not support nested objects?

穿精又带淫゛_ 提交于 2019-12-10 18:44:44
问题 I'm new to Java so this may not be related to AWS lambda at all. However, lambda takes such liberties with input/output objects that I'm assuming it's the culprit here. I'm building my first lambda function and want to return a simple JSON structure (simplified further for this example): { "document" : "1", "person" : { "name" : "John Doe" } } However, when lambda serializes the JSON it always sets "person" to a blank object! { "document": "1", "person": {} } Here is my code in full: - test1

AWS Lambda and SQL Server Integration

谁说胖子不能爱 提交于 2019-12-10 18:29:11
问题 My application uses MS Sql Server. Now after knowing about AWS Lambda, I want to shift my application to AWS Lambda to have server-less architecture. But as I mentioned, application uses Sql Server. So I am not sure if AWS Lambda supports connection with Sql Server. Any comments/ links will be helpful. 回答1: Yes, you can connect from lambda to sql server, and as far as I know, just about anything other database. There are very few limitations on what you can do inside a lambda function. 回答2:

How does Amazon CloudWatch batch logs when streaming to AWS Lambda?

允我心安 提交于 2019-12-10 18:28:16
问题 The AWS documentation indicates that multiple log event records are provided to Lambda when streaming logs from CloudWatch. logEvents The actual log data, represented as an array of log event records. The "id" property is a unique identifier for every log event. How does CloudWatch group these logs? Time? Count? Randomly, from my perspective? 回答1: Some aws services allow you to configure the log intervals such as elastic load balancing. There's a choice between five and sixty minute log

Why Does AWS Lambda function finishes before callback function is executed?

爷,独闯天下 提交于 2019-12-10 18:25:09
问题 I am working on a project to get the transcript out of an audio file. Audio files are of the format flac. I am using AWS Lambda and have written the code in node. Also, I am using IBM Speech to text service and using the basic example code given by them which can be found here. The problem is that my lambda function finishes before running these functions. I am downloading a file from s3 and storing it locally(which is working fine). After that, I am trying to pass the same file to IBM Speech

Download files using AWS Lambda

无人久伴 提交于 2019-12-10 18:24:44
问题 I have an iOS app that calls a AWS Lambda function. I would like the Lambda function to get some files from a server and send it back to the iOS app, through the Lambda proxy feature. I am directly invoking the Lambda function from my app using the generated SDK. I couldn't find a documentation explaining how to exchange data other than JSON encoded requests. How should I go about this? 回答1: Lambda's only interface to the outside world is JSON. To return text data from Lambda, you have to