aws-lambda

How do I return a message back to SQS from lambda trigger

随声附和 提交于 2020-01-14 05:33:08
问题 I have lambda trigger that reads messages from SQS queue. In some conditions, the message may not be ready for processing so I'd like to put the message back in queue for 1min and try again. Currently, I am create another copy of this customer record and posting this new copy in the queue. Is there a reason/way for me to keep the original record in queue as opposed to creating a new one def postToQueue(customer): if 'attemptCount' in customer.keys(): attemptCount = int(customer["attemptCount"

Access web within AWS Lambda

穿精又带淫゛_ 提交于 2020-01-14 05:17:49
问题 I'd like to define a lambda. When it receives a POST request, I'd like to make another POST request to an external uri (say, splunk or apigee or anything outside of AWS). Is this possible? Does Lambda allow the internet access? I googled but did not find a good answer for this one. 回答1: Yes, you can run pretty much any code that you would run on a normal EC2 instance. For instance, if you write your Lambda in node.js you can use the request library to make HTTP calls out to other webservices.

AWS Lambda in VPC sometimes doesn't have internet access

假如想象 提交于 2020-01-14 01:43:06
问题 I have Lambda which was deployed to VPC. This deploymens has next configs: VPC (192.168.0.0/16) Public Subnet A (192.168.32.0/20) has NAT Gateway and Route 0.0.0.0/0 to Internet Gateway Private Subnet A (192.168.48.0/20) has Route 0.0.0.0/0 to NAT Gateway Private Subnet B (192.168.64.0/20) Lambda has own Securiy Group and references to "Private Subnet A" and "Private Subnet B" I have strange problem: time to time Lambda doesn't have Internet Access . 3rd party service works normal. One more

AWS Lambda and Redis client. Why can't I call callback?

試著忘記壹切 提交于 2020-01-13 13:50:01
问题 I'm trying to write an AWS Lambda function which uses Redis. When I run the code below: 'use strict' function handler (data, context, callback) { const redis = require("redis") const _ = require("lodash") console.log('before client') const client = redis.createClient({ url: 'redis://cache-url.euw1.cache.amazonaws.com:6379', }) console.log('after client') callback(null, {status: 'result'}) console.log('after callback') } exports.handler = handler I have an answer like this: { "errorMessage":

AWS Cognito adminCreateUser from Lambda

筅森魡賤 提交于 2020-01-13 10:13:43
问题 I'm trying to create a user in a AWS User Pool from an AWS Lambda I tried with this script took from what seems to be the official JavascriptSDK for the AWS but can't get it working. http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#adminCreateUser-property I keep getting this error: TypeError: cognitoidentityserviceprovider.adminCreateUser is not a function 'use strict' const AWS= require('aws-sdk'); exports.handler = (event, context, callback) => {

Accessing Meta Data from AWS S3 with AWS Lambda

牧云@^-^@ 提交于 2020-01-13 09:13:46
问题 I would like to retrieve some meta data I added (using the console x-amz-meta-my_variable) every time I upload an object to S3. I have set up lambda through the console to trigger every time an object is uploaded to my bucket I am wondering if I can use something like variable = event['Records'][0]['s3']['object']['my_variable'] to retrieve this data or if I have to connect back to S3 with the bucket and key and then call some function to retrieve it? Below is the code: from __future__ import

Write to a specific folder in S3 bucket using AWS Kinesis Firehose

安稳与你 提交于 2020-01-13 09:05:52
问题 I would like to be able to send data sent to kinesis firehose based on the content inside the data. For example if I sent this JSON data: { "name": "John", "id": 345 } I would like to filter the data based on id and send it to a subfolder of my s3 bucket like: S3://myS3Bucket/345_2018_03_05. Is this at all possible with Kinesis Firehose or AWS Lambda? The only way I can think of right now is to resort to creating a kinesis stream for every single one of my possible IDs and point them to the

Running AWS SAM projects locally get error

放肆的年华 提交于 2020-01-13 08:32:26
问题 I am trying to run an AWS Lambda project locally on Ubuntu. When I run the project with AWS SAM Local it shows me this error: Error: Running AWS SAM projects locally requires Docker. Have you got it installed? 回答1: I had trouble installing it on Fedora. When I followed the Docker postinstall instructions I managed to get past this issue. https://docs.docker.com/install/linux/linux-postinstall/ I had to: Delete the ~/.docker directory; Create the "docker" group; Add my user to the "docker"

aws lambda with rds mysql DDL command not working

心已入冬 提交于 2020-01-13 06:52:35
问题 I have created lambda function which is successfully connected to database when using DML command like "Select" or "insert" but when i am try to "created database" or "create table" its return success but table or database not created into RDS . in-short insert query insert records and select return same records so no issue in connection but create commands not working. Followings are my lambda policy const mysql = require('mysql'); const con = mysql.createConnection({ host : process.env.RDS

AWS Lambda exports class works in node.js v6.4 but not in node.js v4.3, how to fix this? [duplicate]

烈酒焚心 提交于 2020-01-13 05:26:11
问题 This question already has answers here : Node.js support for => (arrow function) (4 answers) Closed 3 years ago . I have code works in node.js v6.4: just two files, index.js: // ------------ Index.js ------------ 'use strict'; var Event = require('./models/event.js'); exports.handler = (event, context, callback) => { console.log('done'); } and event.js: // ------------ Event.js ------------ class Event { static get dynamoDBTableName() { return } get hashValue() { return } parseReference