aws-lambda

custom authorizers in Amazon API Gateway 500 error

别等时光非礼了梦想. 提交于 2019-12-30 09:27:46
问题 I use Serverless-Authentication-boilerplate and want to map custom error response. But it always return 500 error. authorize.js // Authorize function authorize(event, callback) { let providerConfig = config(event); try { let data = utils.readToken(event.authorizationToken, providerConfig.token_secret); console.log("Decrypted data: " + JSON.stringify(data)); let methodArn = event.methodArn.replace(/(GET|POST|PUT|DELETE)/g, '*').replace(/mgnt.+/g, 'mgnt/*'); console.log(`Change methodArn to: $

Error: connect ETIMEDOUT rds lambda

巧了我就是萌 提交于 2019-12-30 08:05:41
问题 I am trying to connect to RDS using Lambda function, but I am getting an error: var mysql = require('mysql'); exports.handler = function(event, context) { //Connect to RDS var connection = mysql.createConnection({ host : 'hostname', user : 'username', password : 'password', database : 'database' }); connection.connect( function(err) { if (err) { throw err; } else { console.log('DB connection establish'); } }); }; The error I am getting is: START RequestId: 9711e650-e582-11e5-af5f-97ba391a42ae

Alexa Skill not recognized when tested on Echo

自闭症网瘾萝莉.ら 提交于 2019-12-30 05:47:07
问题 I was doing one of the tutorials (HelloWorld) to make a skill for the Echo and I followed the directions. When I tested the skill using the Service Simulator, I typed in Alexa, tell Greeter to say hello and that returned the following JSON response: { "version": "1.0", "response": { "outputSpeech": { "type": "PlainText", "text": "Hello World!" }, "card": { "content": "Hello World!", "title": "Greeter", "type": "Simple" }, "shouldEndSession": true }, "sessionAttributes": {} } I think that is

InvalidParameterValueException: The role defined for the function cannot be assumed by Lambda

为君一笑 提交于 2019-12-30 04:41:07
问题 I'm using the AWS SDK for JavaScript and it is returning the following error when I try to create a Lambda function: InvalidParameterValueException: The role defined for the function cannot be assumed by Lambda. I've double-checked my role and it is perfectly valid. However, I'm still unable to create the Lambda function. My role trust relationship is: { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": [ "lambda.amazonaws.com" ] }, "Action": [ "sts

AWS Lambda triggered by PUT to s3 bucket in separate account

自闭症网瘾萝莉.ら 提交于 2019-12-30 04:29:15
问题 I am trying to trigger a Lambda function to run on update to a s3 bucket. The s3 bucket that I am attempting to have trigger the Lambda is in a separate AWS account. The approach I have tried is setting up a role in the account that with the s3 bucket that has all the privileges on the s3 bucket. Then in the account with the Lambda I have a role with assumes the role in the other account like this: { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "sts:AssumeRole" ],

Request validation using serverless framework

巧了我就是萌 提交于 2019-12-30 04:29:08
问题 I am using serverless framework for the backend. How can I implement request validation? (do not want to write validation inside lambda functions). 回答1: To implement request validation using serverless you need to do a couple of things: Include your model/header definitions in your stack, and then tell API gateway to use them for request validation. You'll need to install the following packages: serverless-aws-documentation serverless-reqvalidator-plugin And then you'll need to include them

Why can't an AWS lambda function inside a public subnet in a VPC connect to the internet?

风格不统一 提交于 2019-12-30 04:17:26
问题 I've followed the tutorial here to create a VPC with public and private subnets. Then I set up an AWS lambda function inside the public subnet to test if it could connect to the outside internet. Here's my lambda function written in python3 import requests def lambda_handler(event, context): r = requests.get('http://www.google.com') print(r) The function above failed to fetch the content of http://www.google.com when I set it inside the public subnet in a VPC. Here's the error message:

Adding session attributes in Python for Alexa skills

泄露秘密 提交于 2019-12-30 03:35:14
问题 I have 3 slots ( account , dollar_value , recipient_first ) within my intent schema for an Alexa skill and I want to save whatever slots are provided by the speaker in the session Attributes. I am using the following methods to set session attributes: def create_dollar_value_attribute(dollar_value): return {"dollar_value": dollar_value} def create_account_attribute(account): return {"account": account} def create_recipient_first_attribute(recipient_first): return {"recipient_first": recipient

Cognito User Pool: How to refresh Access Token using Refresh Token

拈花ヽ惹草 提交于 2019-12-29 11:33:32
问题 I am using Cognito user pool to authenticate users in my system. A successful authentication gives an ID Token (JWT) , Access Token (JWT) and a Refresh Token . The documentation here, clearly mentions that the refresh token can be used to refresh access token, but does not mention how. My question is once my Access Token expires, how do I use the stored refresh token to refresh my access token again? I searched through the JavaScript SDK and could not find any method to do the same. I

How to test aws lambda functions locally

房东的猫 提交于 2019-12-29 06:36:45
问题 I have a mobile application backend developed with node.js express. I tried it to deploy it as lambda service. For that I created a Serverless Framework project (https://github.com/serverless). Previously I tested mobile app locally by starting express backend application. Now I can't find a method to test my mobile app locally without local backend. jaws run command only run once I called it. Is there any method to start the lambda function as a web service? Or is there any alternative to