aws-lambda

Why is dagger considered better for AWS lambda implementation than Guice?

不想你离开。 提交于 2020-05-16 03:41:36
问题 I know that dagger creates injection at compile time by generating code and hence its performance is better than Guice, which do it at runtime. But specifically for case of lambda, I see it mentioned at multiple places that Dagger is preferred. Is it because of the cold start problem? Because of the cold start problem in lambda, lambda keeps doing bootstrapping multiple times whenever it receives a request after long time. So, with dagger, bootstrapping would be much faster as compared to

Limit concurrent invocation of a AWS Lambda triggered from AWS SQS (Reserved concurrency ignored)?

♀尐吖头ヾ 提交于 2020-05-15 21:46:53
问题 To me this seemed like a simple use case when I started, but it turned out a lot harder than I had anticipated. Problem I have an AWS SQS acting as a job queue that triggers a worker AWS Lambda. However since the worker lambdas are sharing non-scalable resources it is important to limit the number of concurrent running lambdas to (for the sake of example) no more than 5 lambdas running simultaneously. Simple enough, according to Managing Concurrency for a Lambda Function Reserved concurrency

How to trigger an event everytime a notification is pushed on my AWS SQS destination?

一笑奈何 提交于 2020-05-15 09:27:07
问题 I am using AWS SQS for Amazon MWS Order APIs. Everytime someone orders from a seller account who has added me as his developer, Amazon will send the notification to my AWS SQS Application.I can pull the notifications from there. But for this, I will have to create a scheduler to pull the notifications. Can I use any other AWS as a listener just to trigger my own service everytime a notification is pushed on my destination by Amazon? Can I use Lambda functions for it? I am new to AWS so I know

Why values are not inserted into DynamoDB unless calling `.promise()`?

倖福魔咒の 提交于 2020-05-15 09:25:29
问题 I have some simple async code in a lambda, fetching some data and then inserting that into DynamoDB. With this code, everything works as expected: const AWS = require('aws-sdk'); const docClient = new AWS.DynamoDB.DocumentClient({ region: 'eu-west-1', apiVersion: 'latest' }); function fetchSomething() { return new Promise((resolve) => { setTimeout(() => { resolve({ foo: 'Foo', bar: 'Bar' }); }, 2000); }) } exports.handler = async (event) => { try { const data = await fetchSomething(); const

aws lambda function async connection query

非 Y 不嫁゛ 提交于 2020-05-15 08:39:04
问题 I have a function connect to amazon RDS and select data from a table, but my callback function always return result is undefined. I used async/await for this function but it does't work. My problem: I need function getOrder must be finished and return a result, after that call to callback. My function: 'use strict'; let mysql = require('mysql'); let config = require('./config'); let pool = mysql.createPool({ connectionLimit : 10, host : config.host, user : config.user, password : config

Decimal in input JSON to Python 3 Lambda Function

家住魔仙堡 提交于 2020-05-15 02:40:25
问题 Consider the following input in a financial application, where precision matters: { "value": 3.8 } And the following AWS Lambda function: from decimal import Decimal def lambda_handler(event, context): value = event['value'] print(Decimal(value)) The output is: 3.79999999999999982236431605997495353221893310546875 because Python parsed the number in the JSON into a float, which can't precisely store 3.8. I know that I can serialize event back to a string and then instruct the parser to use

Split S3 file into smaller files of 1000 lines

一曲冷凌霜 提交于 2020-05-15 01:59:11
问题 I have a text file on S3 with around 300 million lines. I'm looking to split this file into smaller files of 1,000 lines each (with the last file containing the remainder), which I'd then like to put into another folder or bucket on S3. So far, I've been running this on my local drive using the linux command: split -l 1000 file which splits the original file into smaller files of 1,000 lines. However, with a larger file like this, it seems inefficient to download and then re-upload from my

AWS API Gateway: How do I make querystring parameters optional in mapping template?

血红的双手。 提交于 2020-05-14 17:56:06
问题 I can't seem to figure out how to create optional query string parameters using a mapping template within my resource's Integration Request. My template looks like this: { "limit": "$input.params('limit')", "post_date":"$input.params('post_date')" } I'd like 'limit' & 'post_date' to be optional. This template creates a querystring that looks like this when these parameters are not provided: /myresource?limit=undefined& When I'm expecting: /myresource The Docs don't seem to cover this. I have

Serve index file instead of download prompt

点点圈 提交于 2020-05-14 01:19:59
问题 I have my website hosted on S3 with CloudFront as a CDN, and I need these two URLs to behave the same and to serve the index.html file within the directory: example.com/directory example.com/directory/ The one with the / at the end incorrectly prompts the browser to download a zero byte file with a random hash for the name of the file. Without the slash it returns my 404 page. How can I get both paths to deliver the index.html file within the directory? If there's a way I'm "supposed" to do

Serve index file instead of download prompt

会有一股神秘感。 提交于 2020-05-14 01:18:27
问题 I have my website hosted on S3 with CloudFront as a CDN, and I need these two URLs to behave the same and to serve the index.html file within the directory: example.com/directory example.com/directory/ The one with the / at the end incorrectly prompts the browser to download a zero byte file with a random hash for the name of the file. Without the slash it returns my 404 page. How can I get both paths to deliver the index.html file within the directory? If there's a way I'm "supposed" to do