aws-lambda

AWS Lambda de-serializer / LinkedHashmap cannot cast

a 夏天 提交于 2019-12-13 15:19:09
问题 I'm new to Java/AWS etc., and AWS lambda we not de-serialize what I think is a trivial example. The API Gateway log, which is sending JSON to my lambda: Execution log for request test-request Mon Sep 11 18:04:06 UTC 2017 : Starting execution for request: test-invoke-request Mon Sep 11 18:04:06 UTC 2017 : HTTP Method: POST, Resource Path: / Mon Sep 11 18:04:06 UTC 2017 : Method request path: {} Mon Sep 11 18:04:06 UTC 2017 : Method request query string: {} Mon Sep 11 18:04:06 UTC 2017 : Method

error: No usable messages given the current slot and sessionAttribute set

点点圈 提交于 2019-12-13 15:00:32
问题 I made a chatbot in lex and for one particular intent, Lex is throwing the error, An error has occurred: Invalid Bot Configuration: No usable messages given the current slot and sessionAttribute set. This error comes regardless of the input in case of that intent. I am not using any lambda functions at this point for this intent. Can someone guide me what this means? I am new to lex and I did not find references to what this error is about. 回答1: Recently I got the same error with the test of

What's the correct way of returning HTTP error codes in serverless lambda

北城以北 提交于 2019-12-13 14:45:08
问题 I have a serverless lambda function written in Node.JS. What is the best / correct way of returning error codes? The pattern that I use right now ( and it works! ) is: module.exports.endpoint = (event, context, callback) => { const response = { statusCode: 404, body: JSON.stringify({ message: 'Hello World!' }) }; callback(null, response); } When I make a call, for example from POSTMAN, to my endpoint I get: Status: 404 Not Found which is exactly what I'm expecting . Moreover, in the logs I

Is it possible to use TypeScript with 'aws-sdk-mock'

走远了吗. 提交于 2019-12-13 14:06:25
问题 I'm writing unit tests for a serverless application in TypeScript, and I'd like to mock the AWS SDK. Unfortunately I have not found many existing type definitions for popular AWS mocking projects. In particular I'd like to use the aws-sdk-mock library, but without its type definitions I can't. Theoretically I'd like to be able to do something like: import 'jest'; import * as sinon from 'sinon'; import * as _ from 'lodash'; import { handler } from '../lib/lambda'; import AWSMock from 'aws-sdk

AWS API Gatewat with proxy Lambda: Invalid permissions on Lambda function

こ雲淡風輕ζ 提交于 2019-12-13 14:01:54
问题 I am using AWS API Gateway with a proxy Lambda, when the name of the lambda function is coming as a stage variable. Meaning I have a single API integration which connects to appropriate lambda according to the deployed stage. See the general idea here: When I test one of my stages (called: "staging") everything works fine, but when testing the other stage ("production") I get the error "Execution failed due to configuration error: Invalid permissions on Lambda function". Things I already

SQS Lambda - retry logic?

百般思念 提交于 2019-12-13 12:57:22
问题 When the message has been added to an SQS queue and it is configured to trigger a lambda function (nodejs). When a lambda function is triggered - I may want to retry same message again after 5 minute without deleting the message from the Queue. The reason I want to do this if Lambda could not connect external host (eg: API) - i like to try again after 5 minutes for 3 attempts only. How can that be written in node js? For example in Laravel, we can Specifying Max Job Attempts functionality.

Cognito user pool authorizer With Serverless Framework

廉价感情. 提交于 2019-12-13 11:36:15
问题 I need to authorize my API end point using aws cognito userpool. I can do it manually, but I need to automate the authorization part with the serverless framework. Does the Serverless framework have support for aws cognito? If so, how do we setup an aws-userpool with serverless? 回答1: Yes . Serverless ( v1.5 ) support to Cognito user pool authorizer. If you use previous version of serverless you have to update v1.5 or later. For the user-pool authorization of api end point you have to specify

MQTT in AWS Lambda function for Alexa Javascript

天涯浪子 提交于 2019-12-13 07:17:31
问题 Please help, I need to use mqtt protocol in lambda function to send some data to a broker. I use simple code to test it : mqtt = require('mqtt'); var client = mqtt.connect('mqtt://test.mosquitto.org'); client.on('connect', function () { client.subscribe('presence'); client.publish('presence', 'Hello mqtt'); }); client.on('message', function (topic, message) { // message is Buffer console.log(message.toString()); client.end(); }); But I get an error "Cannot find module 'mqtt'", how can I

How to convert a CURL request into an axios request?

隐身守侯 提交于 2019-12-13 07:17:26
问题 I just successfully curled here: curl -X POST https://jenkins-url/job/MyJob/job/some-job/job/master/build --user myemail:mypassword -H 'Jenkins-Crumb: mycrumb' now I want to use axios inside my lambda so I have this: const axios = require('axios') exports.handler = async (event) => { const url = "my-url"; try { const res = await axios.post(url, {}, { auth: { username: 'user', password: 'passowrd' }, headers: { "Content-Type": "application/x-www-form-urlencoded", "Jenkins-Crumb": "my-crumb" },

Is it safe to authenticate a Cognito User through API Gateway to Lambda using a custom property?

微笑、不失礼 提交于 2019-12-13 06:59:46
问题 I'm currently using a Cognito User Pool as an authorizer for an API Gateway endpoint, through to a Lambda function. Can I pass the Integrated Request on to Lambda and SECURELY allow or deny from inside Lambda based on a custom attribute? Mapping: "administrator" : "$context.authorizer.claims['custom:administrator']", Lambda handler: boolean isAdmin = Boolean.parseBoolean(request.getContext().get("administrator")); if(isAdmin) etc... To be clear, a user that is NOT an administrator should not