aws-lambda

How do I cloudform an API gateway resource with a lambda proxy integration

喜你入骨 提交于 2020-01-01 01:35:50
问题 I've been trying to work out how to express (in cloudformation) an API Gateway Resource that has a Lambda function integration type using the Lambda Proxy integration. This is easy to do in the AWS console as there is a check box that you can select: However there is no corresponding field in the AWS::ApiGateway::Method CloudFormation resource (it should be in the Integration property). How can I configure this in cloudformation? 回答1: The Integration type should be set to AWS_PROXY . An

using Python 3 with AWS lambda

孤人 提交于 2019-12-31 20:02:13
问题 Can one use application built with Python3 in lambda, and not just python2.7. Possibly looking at options around - https://gun.io/blog/announcing-zappa-serverless-python-aws-lambda/ AWS lambda documentation mentions about python2.7. Is there some example code which I could try for python3.0 with lambda 回答1: Lambda functions run in a container on a well-known AMI. While you must handle the initial event with Python2.7, you can call out to anything installed on the AMI. In particular, Python3

SNS to Lambda vs SNS to SQS to Lambda

夙愿已清 提交于 2019-12-31 13:00:35
问题 I'm trying to understand whether I need SQS in my workflow if someone can help explain. In my app, when an action is taken, it submits info to SNS topic which invokes LAMBDA to do some processing. This is working great as it is. When I do research online, it seems that people are using SQS in this stack as well where SNS would put info on SQS and then SQS would then invoke LAMBDA. I guess what I'm trying to understand is the need for SQS in this. What value doe that add or in other words,

Send an SMS via AWS SNS using boto3 in an AWS Lambda function?

喜欢而已 提交于 2019-12-31 10:39:52
问题 I would like to send an SMS message from an AWS Lambda function using the boto3 publish method to notify the user of issues via SMS. My lambda function is written in Python and I am using the boto3 module. My lambda function has full rights to SNS. I have this code, sns = boto3.client('sns') sns.publish( PhoneNumber = '+11234567890', Message = 'Simple text message' ) According to the boto3 documentation, the publish method accepts the following parameters, response = client.publish( TopicArn=

Lambda + Python + Exit Code

泄露秘密 提交于 2019-12-31 03:22:06
问题 I've encountered an issue with a simple AWS Lambda function written in Python. When I run my Lambda function, my code is running as expected, the result is correct, but still ends with an error code (exit code): "Process exited before completing request" , this is causing the Lambda to run 3 times (async). Do you have any best practice to manage the exit code for Lambda ? #!/usr/bin/python import boto3 import sys import tweepy import datetime session = boto3 # Init s3 client s3 = session

AWS DynamoDB trigger using Lambda in JAVA

牧云@^-^@ 提交于 2019-12-31 00:45:12
问题 I am trying to trigger an AWS lambda function written in Java, on dynamodb stream events. Amazon has a guide for the same, using NodeJS here http://docs.aws.amazon.com/lambda/latest/dg/wt-ddb-create-test-function.html The testing input for NodeJS (from the above link) looks like an SNS event, so I tried to use the corresponding SNSEvent class in Java as an input to my handler method. import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime

AWS Python Lambda with Oracle - OID Generation Failed

风流意气都作罢 提交于 2019-12-31 00:39:13
问题 I'm trying to connect to an Oracle DB using AWS Lambda Python code. My code is below: import sys, os import cx_Oracle import traceback def main_handler(event, context): # Enter your database connection details here host = "server_ip_or_name" port = 1521 sid = "server_sid" username = "myusername" password = "mypassword" try: dsn = cx_Oracle.makedsn(host, port, sid) print dsn connection = cx_Oracle.Connection("%s/%s@%s" % (username, password, dsn)) cursor = connection.cursor() cursor.execute(

How can we copy s3 files between buckets of different account/credentials using s3 cp and different profiles?

不问归期 提交于 2019-12-30 23:03:26
问题 I created two profiles (one for source and one for target bucket) and using below command to copy: aws s3 cp --profile source_profile s3://source_bucket/file.txt --profile target_profile s3://target_profile/ But it throws below error. fatal error: An error occurred (403) when calling the HeadObject operation: Forbidden Looks like we can't use multiple profiles with aws commands. 回答1: The simplest method is to grant permissions via a bucket policy. Say you have: Account-A with IAM User-A

How to make different AWS API gateway environments point to different aliases of a lambda function?

僤鯓⒐⒋嵵緔 提交于 2019-12-30 11:21:22
问题 In my AWS API Gateway API, I've set up 2 environments, "dev" and "prod". I also have 2 aliases for an AWS lambda function named "dev" and "prod". Now, I'd like to point the "dev" environment of my API to the "dev" alias of my function, and the "prod" environment at the "prod" alias of my function. I read in a tutorial that I can't find anymore at the moment, that in the integration configuration, you can specify the function in the form <functionName>:<alias> , so I set up the integration to

AWS Lambda - NodeJS POST request and asynch write/read file

偶尔善良 提交于 2019-12-30 10:36:13
问题 I am new to NodeJS and inside of AWS Lambda I am trying to make a POST request that calls an external API with a JSON object, creates a document with the response and then reads the contents of the file. Coming from a Ruby background, I'm thinking the problem stems from my unfamiliarity with asynchronous programming, but I've tried using callbacks and readfileSync just to debug with no luck. Any help would be appreciated. var querystring = require('querystring'); var https = require('https');