aws-lambda

Lambda log and CloudWatch PutLogEvents limit

血红的双手。 提交于 2019-12-23 22:26:19
问题 I know Lambda calls PutLogEvents to log messages internally. CloudWatch has a limit on PutLogEvents . PutLogEvents: 5 requests per second per log stream. I want to know Could Lambda log stream also be throttled by PutLogEvents ? If so, how to know if a Lambda log stream is throttled or not? Any error message in the log stream? When does Lambda call PutLogEvents ? for example, at the end of a Lambda function, it calls PutLogEvents once. when flushing buffer(stdout), it calls PutLogEvents all

Installing Python dependencies in AWS Codestar with Lambda

余生颓废 提交于 2019-12-23 22:23:18
问题 I'm trying out AWS Codestar. My objective is to deploy a non-trivial lambda endpoint, that is, where the handler has dependencies. Ideally, I'd like to be able to specify them in a requirements.txt file somewhere but this seems not to be so straightforward. Specifically, I would like to deploy a lambda handler that depends on nltk and where the files for the nltk tokenizer "punkt" are downloaded as part of the Codebuild process and packaged up for Lambda. How can this be done through

AWS Lambda: call function from another AWS lambda using boto3 invoke

雨燕双飞 提交于 2019-12-23 21:52:14
问题 I have simple lambda function that is located under following endpoint: https://******.execute-api.eu-west-2.amazonaws.com/lambda/add?x=1&y=2 AWS Chalice was used for adding simple endpoints here. @app.route('/{exp}', methods=['GET']) def add(exp): app.log.debug("Received GET request...") request = app.current_request app.log.debug(app.current_request.json_body) x = request.query_params['x'] y = request.query_params['y'] if exp == 'add': app.log.debug("Received ADD command...") result = int(x

How to return error collection/object from AWS Lambda function and map to AWS API Gateway response code

亡梦爱人 提交于 2019-12-23 21:14:53
问题 I am attempting to return an object from a AWS Lambda function instead of a simple string. // ... context.fail({ "email": "Email address is too short", "firstname": "First name is too short" }); // ... I have already used the errorMessage for mapping error responses to status codes and that has been great: // ... context.fail('That "username" has already been taken.'); // ... Am I simply trying to do something that the AWS API Gateway does not afford? I have also already found this article

How to make calls to elasticsearch apis through NodeJS?

放肆的年华 提交于 2019-12-23 19:59:46
问题 I have been tasked with making a POST api call to elastic search api, https://search-test-search-fqa4l6ubylznt7is4d5yxlmbxy.us-west-2.es.amazonaws.com/klove-ddb/recipe/_search I don't have any previous experience with making api calls to AWS services. So, I tried this - axios.post('https://search-test-search-fqa4l6ubylznt7is4d5yxlmbxy.us-west-2.es.amazonaws.com/klove-ddb/recipe/_search') .then(res => res.data) .then(res => console.log(res)); But I was getting {"Message":"User: anonymous is

AWS lambda capture IoT registry event

≯℡__Kan透↙ 提交于 2019-12-23 19:52:02
问题 I'm plan to generate new thing in AWS IoT Registry and once the thing is generated successfully, write the thing arn, thing name, cert information into AWS RDS database. Is this possible to use lambda capture IoT registry event and trigger lambda to write into database? Any suggestion? 回答1: AWS IoT publishes a lot of its events through it's own MQTT broker. In your case you're interested in the $aws/events/thing/<thingName>/created topic (https://docs.aws.amazon.com/iot/latest/developerguide

Why AWS lambda functions In a VPC sometimes timeout and sometimes work fine?

£可爱£侵袭症+ 提交于 2019-12-23 19:44:22
问题 I have some lambda functions in a VPC, some of them need Internet to work so I added a NAT instance (t2.micro) and the problem is that I have some functions sometimes work and sometimes timeout. For example a function that call FB API 80% of the time work and 20% timeout. Another function is using boto3 to create a spot instance 50% of the time timeout and the logs give me. 2018-07-16T06:35:55.909Z 421f98dd-88c2-11e8-913a-63c8d6f276f3 Task timed out after 100.10 seconds Whenever I redeploy my

How to Enable CORS for an AWS API Gateway Resource

▼魔方 西西 提交于 2019-12-23 19:40:22
问题 I created REST API using AWS API Gateway & AWS Lambda and when I configured CORS I faced with such issue - I was able to configure CORS response headers for OPTIONS method, but didn't for GET method. I made it according Amazon documentation, but when I called GET method I didn't see required headers (Access-Control-Allow-Methods, Access-Control-Allow-Headers, Access-Control-Allow-Origin) in response. Due to that I got errors on client side: Failed to load #my_test_rest#: No 'Access-Control

Amazon Cloudwatch log filtering - JSON syntax

泄露秘密 提交于 2019-12-23 19:37:25
问题 I have an AWS Lambda function which is logging errors. Errors are logged as such: console.error(err); I'm trying to create a Cloudwatch filter which uses their JSON log filtering syntax: { $.errorType = "ValidationException" } I can see the error in the log 2015-11-24T20:26:02.852Z 76800706-2d78-45ed-9068-46ccccafe6af { "errorMessage": "1 validation error detected: Value '[]' at 'xxxxxx' failed to satisfy constraint: Member must have length greater than or equal to 1", "errorType":

FTP in AWS Lambda - Issues Downloading Files (Async/Await)

爷,独闯天下 提交于 2019-12-23 19:20:27
问题 I have been struggling with various FTP Node modules to try and get anything working in AWS Lambda. The best and most popular seems to be "Basic-FTP" that also supports async/await. But I just cannot get it to download files when any code is added beneath the FTP function. I don't want to add the fs functions within the FTP async function as I need to solve what is causing the break when any code below is added and I also have other bits of code to add and work with the downloaded file and it