aws-lambda

Script works on AWS EC2, but not on AWS Lambda after zipping

╄→尐↘猪︶ㄣ 提交于 2019-12-13 20:25:27
问题 I am creating a simple AWS Lambda function using M2Crypto library. I followed the steps for creating deployment package from here. The lambda function works perfectly on an EC2 Linux instance (AMI). This is my Function definition: CloudOAuth.py from M2Crypto import BIO, RSA, EVP def verify(event, context): pem = "-----BEGIN PUBLIC KEY-----\n{0}\n-----END PUBLIC KEY-----".format("hello") bio = BIO.MemoryBuffer(str.encode(pem)) print(bio) return Deployment Package structure: When I run the

VPC-running AWS Lambda sends SQS message only once

為{幸葍}努か 提交于 2019-12-13 20:09:39
问题 I have a NodeJS Lambda function running in a private subnet, with allow all incoming/outgoing policies in both the security group and the NACL (not safe, but they do the job). The private subnet has a NAT gateway sitting in a public subnet of the same VPC, so internet connectivity works. My goal is to send messages to an SQS queue. The Lambda code is this: const AWS = require('aws-sdk') const sqs = new AWS.SQS() exports.handler = (event, context, callback) => { sqs.sendMessage({ MessageBody:

Disable/Enable Lambda SNS Trigger Programmatically

半腔热情 提交于 2019-12-13 19:33:36
问题 I need to programmatically disable a lambda's SNS trigger, however, I seem to be unable to do so. I want this to show "Disabled" in the AWS Lambda console for the function: Here's the code I've tried: function updateEndpoints(endpoints, enable) { const promises = []; endpoints.forEach((endpoint) => { console.log(`${enable ? 'Enabling' : 'Disabling'} Endpoint: ${endpoint}`); promises.push( SNS.setEndpointAttributes({ EndpointArn: endpoint, Attributes: { Enabled: enable ? 'True' : 'False', }, }

How do I call a netlify lambda function from my React app?

百般思念 提交于 2019-12-13 18:18:08
问题 I am new to netlify and the serverless architecture. In react I would normally import an action into my component then call that action which would make a call to the server. Right now I am just trying to test my function locally and Im not sure where to import from or how exactly to call my function to see if it even works. Help would be greatly appreciated. Below is a very basic function Im trying to call to get started. //in functions/test.js import axios from 'axios' exports.handler =

C# Lambda constructor not called in consecutive lambda calls

懵懂的女人 提交于 2019-12-13 17:52:22
问题 I have a c# aws lambda class with some code in its constructor. The lambda method itself is getting called every time I initiate it (with an SNS message post), however, I cannot see the constructor getting called (added log calls to observe from cloudwatch). The constructor only gets called at first launch (after the aws stack creation/update). Is this an expected behaviour? Does aws somehow cache my lambda instances? public class MyLambda { public MyLambda() { Console.WriteLine("Hello from

Python - how to authenticate consult Google Analytics from AWS Lambda?

那年仲夏 提交于 2019-12-13 17:19:55
问题 I have a python script to consult certain data from Google Analytics but im trying to go a little bit further and let Lambda (from amazon web services) do it automatically for me everyday. But i encounter a problem and im stuck with it. I don't know how can i authenticate OAuth 2.0 from the script without using a client_secrets.json file and if there is no other way to do it how and where i should leave the .json file in order to let it authenticate itself. As it explains here since im not

Using PCM format of AWS Polly

我的梦境 提交于 2019-12-13 17:00:26
问题 I am trying to use AWS Polly (for TTS) using JavaScript SDK from AWS lambda (which is exposed through a REST API using API gateway). There is no trouble in getting the PCM output. Here is a call flow in brief. .NET application --> REST API (API gateway) --> AWS Lambda (JS SDK) --> AWS Polly The .NET application (am using POSTMAN too for testing) gets an audio stream buffer in following format. {"type":"Buffer","data":[255,255,0,0,0,0,255,255,255,255,0,0,0,0,0,0,255,255,255,255,0,0,0,0,255,255

AWS Credentials for lambda when working with scala not working

我的梦境 提交于 2019-12-13 16:07:45
问题 AWS lambda function does not work when attempting to work with credentials provided using the DefaultCredentialProvider. I need to pass the credentials to S3 for it to run. Code def initializeAwsCredentials():AWSCredentials = { var credentials: AWSCredentials = null try { credentials = new ProfileCredentialsProvider().getCredentials } catch { case e: Exception => { throw new AmazonClientException( "Cannot load the credentials from the credential profiles file. " + "Please make sure that your

Execution failed due to configuration error: Invalid permissions on Lambda function

荒凉一梦 提交于 2019-12-13 16:06:22
问题 I am building a serverless application using AWS Lambda and API Gateway via Visual Studio. I am working in C#, and using the serverless application model (SAM) in order to deploy my API. I build the code in Visual Studio, then deploy via publish to Lambda. This is working, except every time I do a new build, and try to execute an API call, I get this error: Execution failed due to configuration error: Invalid permissions on Lambda function Doing some research, I found this fix mentioned

Jackson JSON deserialization for Amazon Lex AWS Lambda hook

老子叫甜甜 提交于 2019-12-13 16:00:23
问题 I have a problem with deserialization implemented in AWS Lex Lambda hook. I have an AWS Lambda function to validate the user input, but I keep getting JSONMapping errors. The Lex json is like this: { "currentIntent": { "name": "intent-name", "slots": { "slot-name": "value", "slot-name": "value", "slot-name": "value" }, "confirmationStatus": "None, Confirmed, or Denied (intent confirmation, if configured)", }, "bot": { "name": "bot-name", "alias": "bot-alias", "version": "bot-version" },