aws-lambda

How can I minimize the weight of my lambda functions?

匆匆过客 提交于 2019-12-11 01:18:21
问题 I am trying to build a microservice API using AWS (lambda + s3 + apiGateway) and I have noticed that all my lambdas have the same weight, so it seems like I am uploading the full project to every lambda instead of the needed resources. Is there any way to upload just the resources I need for each function? Will this minimize the execution time? Is it worth to do it? 回答1: Going to answer this in 2 parts: (1) The obligatory "Why do you care?" I ask this because I was really concerned too. But

AWS Lambda invoke function doesn't always return

只谈情不闲聊 提交于 2019-12-11 00:53:11
问题 I am running an AWS Lambda function for image/video processing with Node 4.3 as a runtime. I am invoking my function from my webapp code with the node aws-sdk. The issue is that when the function takes a long time to execute (e.g. 250 seconds), the invocation callback is never received, although I can clearly see in the aws cloudwatch logs that the function executed properly. On top of that the function is re-run again at least twice (this is probably related to the maxRetries parameter from

Lambda can not access RDS though those are in the same VPC

吃可爱长大的小学妹 提交于 2019-12-11 00:47:26
问题 I have created VPC and RDS with the below CloudFormation . Resources: TestVpc: Type: "AWS::EC2::VPC" Properties: CidrBlock: "10.0.0.0/16" EnableDnsSupport: true EnableDnsHostnames: true TestSubnetA: Type: "AWS::EC2::Subnet" Properties: AvailabilityZone: "ap-northeast-1a" CidrBlock: "10.0.0.0/20" VpcId: !Ref TestVpc TestSubnetB: Type: "AWS::EC2::Subnet" Properties: AvailabilityZone: "ap-northeast-1d" CidrBlock: "10.0.16.0/20" VpcId: !Ref TestVpc TestSubnetC: Type: "AWS::EC2::Subnet" Properties

AWS API Gateway and Lambda function deployed through terraform — Execution failed due to configuration error: Invalid permissions on Lambda function

若如初见. 提交于 2019-12-11 00:34:48
问题 I'm deploying an API gateway and a Lambda function together through Terraform, and the Lambda function is meant to be triggered by the API Gateway. After the resources successfully deploy, I test the API Gateway and I get response: { "message": "Internal server error" } . The actual logs of the API gateway say: Execution failed due to configuration error: Invalid permissions on Lambda function I can get the actual api-lambda functionality to work by going to the integration request section of

Unable to deliver worldwide text message from aws lambda function

亡梦爱人 提交于 2019-12-11 00:09:09
问题 I am trying to send OTP from my AWS Lambda function hosted in AP-South-1 (i.e. Mumbai) region. I am using a worldwide text-messaging feature of SNS for this. As the "AP-South-1" region does not support worldwide text-messaging feature, I am sending the SNSClient's region endpoint as "APNortheast1" (i.e. Tokyo) region as it supports worldwide text-messaging. Now, I have given my lambda function administrator privilege (by attaching role with administrator policy). But, still, it doesn't seem

Custom slot types in amazon lex without enumeration values

天大地大妈咪最大 提交于 2019-12-11 00:08:41
问题 I'm trying to build a bot to change userinfo stored in a database. My first thought was to create two slot types like {toChange} and {newValue} where the user could say "Change my name to Peter Griffin" or "My new email is user@mail.com". Turns out Lex can't handle these custom string inputs. I had to create a slot type for each value the user can have: {name} with AMAZON.Person , {address} with AMAZON.PostalAddress and so on and let Lambda handle the correct slots to elicit. The problem is

Load S3 file in lambda before main procedure

ぃ、小莉子 提交于 2019-12-11 00:08:38
问题 I am writing a lambda function that needs to load a key that is being stored in S3. It wont change often so I'd rather not grab it every time the lambda function is called, so I would like to load it once when the container is spun up and then keep that value for the lifetime of the lambda container. However, due to the asynchronous method getObject this is causing an issue as the file may not have been loaded when the main module.export code gets run (particularly if this is the first run

Set LogStreamName for AWS Lambda call

 ̄綄美尐妖づ 提交于 2019-12-10 22:46:55
问题 We deploy node.js functions onto AWS Lambda. When calling them, they auto-generate an AWS CloudWatch log. The log group is set to the name of the Lambda function, that´s helpful. But the log stream is named like this: 2018/02/14/[$LATEST]794dbaf40a7846c4984ad80ebf110544 . That is not helpful when searching for errors since I need to check multiple log streams, because I do not know which one is the correct one. Is there any way to define the log stream name, so that it is more readable for a

Unable to run AWS Lambda function with API Gateway

醉酒当歌 提交于 2019-12-10 22:18:20
问题 I have created a simple python 3.7 lambda function: import json import boto3 s3 = boto3.client("s3") def lambda_handler(event, context): bucket = "nubi-data" key = "core/user.json" try: data = s3.get_object(Bucket=bucket, Key=key) json_data = data['Body'].read() #return json_data return { 'statusCode': 200, "headers": {"Content-Type": "application/json"}, 'body': json.loads(json_data) } except Exception as e: print(e) raise e This function reads a json file from an s3 bucket. The json file

Specifying C(++) dependencies for python packages for use in AWS Lambda

会有一股神秘感。 提交于 2019-12-10 21:03:23
问题 I have a serverless service that I want to be able to use the sasl pypi package from in AWS Lambda. Unfortunately, the AWS Lambda environment doesn't seem to have the newest versions of libstdc++.so, which means that when our build server zips up the pip install 'd sasl package and we invoke the lambda, there are the expected errors: Unable to import module 'handler': /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /var/task/sasl/saslwrapper.so) My question is: How