aws-lambda

How to check the date is empty using python?

。_饼干妹妹 提交于 2020-01-03 05:10:05
问题 The startdate and enddate values are coming from jenkin to lambda. In this code I am trying to get value using event["start_date"] and event["end_date"] and it's working fine, but if startdate and enddate are not available then the code should automatically take today's and yesterday's date. I am new to python, can someone help here? I tried as below but I am getting error. If I will mention 'startdate and enddate is none' and set both values as none then it's working but I need to implement

How can I make my Lambda function talk to a server running on my local machine?

自作多情 提交于 2020-01-03 02:23:29
问题 I am creating a Lambda function that makes a call to some functionality on my server. I would like to test the Lambda function against a local instance of my server, so that I don't have to deploy to AWS in order to test run the whole flow. Is there any way to call my local machine's development server from inside Lambda without having to keep deploying to AWS (or some other remote server)? 回答1: This may be possible if you set up a VPN or Direct Connect between your VPC and your local network

Unable to import module in AWS Lambda (Python)

为君一笑 提交于 2020-01-02 11:03:32
问题 I have a python script named foo.py . It has a lambda handler function defined like this: def handler(event, context): for record in event['Records']: bucket = record['s3']['bucket']['name'] key = record['s3']['object']['key'] download_path = '/tmp/{}.gz'.format(key) csv_path = '/tmp/{}.csv'.format(key) ... proceed to proprietary stuff This is in a zip file like so: -foo.zip -foo.py -dependencies I have uploaded this zip file to AWS Lambda and configured an AWS Lambda Function to run foo

AWS API Gateway default response and Trigger AWS Lambda

百般思念 提交于 2020-01-02 10:18:12
问题 I have been experimenting with AWS API Gateway and AWS Lambda to try out a serverless architecture. Have been going through blogs and AWS documentation. Have tried out sample GET/POST. But, I have the following requirement w.r.t tracking user events from my custom application Events are posted from my application to API end point I wanted the API to respond back with a custom response (Say {'fine'}) (acknowledging that the request has been received) After the response is sent, hand over the

converting PDF to JPEG on AWS Lambda

Deadly 提交于 2020-01-02 09:37:10
问题 I've written a small lambda Python function that makes use of pdf2image to convert a PDF file's pages into separate JPG files. This library is a wrapper around poppler-utils , in particular pdftoppm . Works fine on my Ubuntu system, but of course AWS Lambda is different. So I went to look for a version of poppler that I could compile on an EC2 instance for AWS Lambda and found the slightly dated Poppler-build ansible playbook. With some tweaks, I got it to work, however the Poppler version

node-canvas build for AWS Lambda

▼魔方 西西 提交于 2020-01-02 08:48:51
问题 I'm a Linux & node noob. I'm trying to run FabricJS (which requires node-canvas) in AWS Lambda. I've been able to follow the instructions to get up and running on an AWS Linux EC2, however, Lambda has me at my wits end. Anyone have any tips or pointers on how to get this compiled for AW Lambda? 回答1: I found this issue in the Node Canvas GitHub site. The questioner was trying to run FabricJS in Lambda as well. Here is the relevant section with an answer: Make sure you're compiling this on the

AWS API Gateway: Regex for error is not picked up

情到浓时终转凉″ 提交于 2020-01-02 05:41:08
问题 I have a Lambda function tied to the AWS API gateway. When I call it with something like /foo/bar and bar does not exist, my function returns (correctly) something like: { "code": 404, "message": "bar not found" } I now want the status code of this to be 404, too, but following the tutorials I could find on the net, I had no success so far. What I did: I created a method response for 404 that looks like this: And in the integration response, I set the following: To my understanding, this

Using AWS Secrets Manager with Python (Lambda Console)

你。 提交于 2020-01-02 05:13:11
问题 I am attempting to use Secrets Manager a Lambda function in AWS. Secrets a manager is used to store database credentials to Snowflake (username, password). I managed to set up a secret in Secrets Manager which contains several key/value pairs (e.g. one for username, another for password). Now I am trying to refer to these values in my Python function code. AWS documentation kindly provides the following snippet: import boto3 import base64 from botocore.exceptions import ClientError def get

“KeyError: 'Records'” in AWS S3 - Lambda trigger

*爱你&永不变心* 提交于 2020-01-02 02:38:13
问题 I have the following lambda function code for simply printing out the Author and metadata of an uploaded event of an S3 bucket: from __future__ import print_function import json import urllib import boto3 print('Loading function') s3 = boto3.client('s3') def lambda_handler(event, context): #print("Received event: " + json.dumps(event, indent=2)) # bucket = event['Records'][0]['s3']['bucket']['name'] for record in event['Records']: bucket = record[0]['s3']['bucket']['name'] key = record[0]['s3

AWS API Gateway CORS ok for OPTIONS, fail for POST

你说的曾经没有我的故事 提交于 2020-01-02 02:22:52
问题 I've looked at the other related questions on SO but this seems different. In fact, my question is very similar to this one, except I don't have the 400 status issue. The set up: lambda function through API Gateway Authorization: None, API KEY Required: false deploying to stage: test 1 resource, 1 POST method integrating the lambda. Calling the POST endpoint directly e.g. with curl always returns 200 (with/without payload, bad payload, etc.) - so that's different from the referenced question.