serverless-framework

Order Results by Priority & Group Values & then filter results

痴心易碎 提交于 2019-12-10 23:06:48
问题 Here is my DynamoDB current data: My goal is to create a query which filters the result in the Group Set (to like "Default") , and then sorts by priority and then filters the results to those where loggedIn == true and status == idle. In SQL it would be something like SELECT * FROM userstatustable WHERE group == "default" AND loggedIn == true AND status == "idle" ORDER BY priority DESC LIMIT 1 How would I create a query to do this? Below is my serverless.yml file description of the DynamoDB

Error compiling Typescript with graphql files

天大地大妈咪最大 提交于 2019-12-10 22:25:05
问题 So I'm new in this area, the thing is that I'm trying to compile a Typescript project with graphql files on it (with .graphql extension). It' based on the serverless framework, so to compile it I launch npm start which launches a cd src/app && tsc in the command line. The .ts file references the .graphql file like this: import SchemaDefinition from './schemaDefinition.graphql'; And the error is data/schema/index.ts(2,30): error TS2307: Cannot find module './schemaDefinition.graphql'. I think

How to define variables in a DRY way

让人想犯罪 __ 提交于 2019-12-10 18:49:45
问题 Let's say I have function that writes to a S3 bucket. So the bucket name is clearly a "variable" that should not be hard-coded into the function (might be different buckets for dev vs. prod, for example). Now, I need to use the bucket name in at least two places if I want the function to be able to access it: In the IAM policy of the function (allowing access to the bucket). In the function itself. For #1 I can use a variable, and refer to the variable in the IAM policy defined in s-module

Badge count option in amazon SNS

烂漫一生 提交于 2019-12-10 16:26:38
问题 I need to get badge count in my application. I am using amazon SNS service. Here is my code AWS.config.update({ accessKeyId: 'XXXXXXX', secretAccessKey: 'XXXXXXX' }) AWS.config.update({ region: 'XXXXXXX' }) const sns = new AWS.SNS() const params = { PlatformApplicationArn: 'XXXXXXX', Token: deviceToken } sns.createPlatformEndpoint(params, (err, EndPointResult) => { const client_arn = EndPointResult["EndpointArn"]; sns.publish({ TargetArn: client_arn, Message: message, Subject: title, // badge

How can I set an AWS Lambda to be invoked asynchronously through HTTP/API Gateway?

邮差的信 提交于 2019-12-10 16:13:06
问题 I am writing an AWS Lambda that is invoked via HTTP (i.e. the API Gateway integration). I wish to use that API as a GitHub webhook. When the webhook/lambda is called I want the HTTP response to be sent right away and the lambda to keep executing (because it can take some time). This is similar to the Event invocation type when invoking a lambda: Event: fire and forget RequestResponse: wait for the response Is that possible to use that invocation type with the HTTP integration? Note: I am

Setting up a NAT gateway with VPC using Serverless framework

风格不统一 提交于 2019-12-10 13:40:20
问题 I'm trying to use the serverless framework to create a Lambda function that can access an Elasticache cluster, as well as call out to the internet. I've got as far as configuring serverless.yml to create the Lambda function, create the Elasticache cluster (memcached engine), and finally to create a VPC and place both the Lambda function and Elasticache cluster within it (otherwise, they cannot communicate). I understand that things within a VPC do not have access to the internet, and from

MoonMail Lambda architecture with Serverless

有些话、适合烂在心里 提交于 2019-12-10 03:09:20
问题 I've been looking into this project because the idea of having the whole system be a collection of Lambda functions seems very appealing. As a matter of fact, a few years ago I wrote some software that does pretty much the same as MoonMail does and it is due for an update as some specs have changed. I'm evaluating porting my software to Lambda or just adapting the thing to use MoonMail. I have the following questions: In my tests using Serverless, I noticed that when I changed a resource name

How to access DynamoDB from AWS Lambda when using the Serverless Framework?

匆匆过客 提交于 2019-12-09 16:06:07
问题 I'm using the Serverless Framework to manage my AWS Lambda deploys. The framework credentials has access to DynamoDB resources, but my Lambda, deployed with the framework, can't access my DynamoDB tables. How can I give my Lambda functions the proper access? 回答1: EDIT : updated the answer for Serverless Framework 1.x. The solution is to set the iamRoleStatements to allow Lambda to access the DynamoDB resources. Note: the credentials used by the Serverless Framework must have permission to the

Serverless Framework with AWS Lambda error “Cannot find module”

六月ゝ 毕业季﹏ 提交于 2019-12-08 17:11:57
问题 I'm trying to use the Serverless Framework to create a Lambda function that uses open weather NPM module. However, I'm getting the following exception, but my node_modules contain the specific library. I have managed to run the sample, (https://github.com/serverless/examples/tree/master/aws-node-rest-api-with-dynamodb) successfully, now hacking to add node module to integrate open weather API. Endpoint response body before transformations: {"errorMessage":"Cannot find module 'Openweather-Node

Serverless Framework with Node MySQL

青春壹個敷衍的年華 提交于 2019-12-08 08:17:11
问题 How to use mysql connection with serverless framework.connection should be available in my component functions without creating mysql connection each time in component function Tried like this var mysql = require('mysql'); module.exports.respond = function(event, cb) { var pool = mysql.createPool({ connectionLimit : 100, host : 'hostname', user : 'username', password : 'password', database : 'databasename', debug : false }); var message=''; pool.getConnection(function(err,connection){ if(err)