Tag: amazon web services

与JS / Node SDK的AWS S3同步

Amazon Web Services(AWS)命令行界面(CLI)具有同步命令 。 不幸的是,AWS CLI的同步方法有点麻烦。 我想使用gulp构build过程和Amazon的javascript / node SDK同步到S3。 不幸的是,SDK似乎没有同步方法 – 或者它? 将节点中的整个目录与AWS S3同步的最佳方法是什么?

无法将请求正文parsing为json:意外字符(\' – \'(code 45))AWS Lambda + API + Postman

我一直在尝试几天,以获取从AWS的API网关发送到Lambda函数的参数,我没有成功。 我决定从头开始,所以我跟着他们的演练( http://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started.html#getting-started-new- lambda ) 我已经检查过这个演练两次,我已经按照这封信的步骤。 问题 当我从Postman或SwifttestingAPI时,出现错误: {“message”:“无法将请求正文parsing为json:数字值中的意外字符(\' – \'(code 45)):期望的数字(0-9)跟随减号,对于有效的数字值\ n at [来源:[B @ c036d15; line:1,column:3]“} 在邮递员,当我看到结果为JSON我刚刚得到 坏string Lambda函数 该function是演练的基本示例: console.log('Loading event'); exports.handler = function(event, context) { var name = (event.name === undefined ? 'No-Name' : event.name); console.log('"Hello":"' + name + '"'); context.done(null, {"Hello":name}); // SUCCESS with message }; 从Lambda控制台和testing数据进行testing时,我得到结果: { "Hello": "TestUser123" […]

使用Lambda节点从S3上的文件创buildS3上的zip文件

我需要创build一个Zip文件,其中包含位于我的s3存储桶中的一系列文件(video和图像)。 目前使用我的代码下面的问题是,我很快达到了Lambda的内存限制。 async.eachLimit(files, 10, function(file, next) { var params = { Bucket: bucket, // bucket name Key: file.key }; s3.getObject(params, function(err, data) { if (err) { console.log('file', file.key); console.log('get image files err',err, err.stack); // an error occurred } else { console.log('file', file.key); zip.file(file.key, data.Body); next(); } }); }, function(err) { if (err) { console.log('err', err); […]

Streaming-s3不能正常升级文件

我正在使用nodejs将file upload到aws服务器。 并发现文件大小不正确。 我得到2.1KB。 这是我的代码 var uploadFile = function (fileReadStream, awsHeader, cb) { //set options for the streaming module var options = { concurrentParts: 2, waitTime: 20000, retries: 2, maxPartSize: 10 * 1024 * 1024 }; //call stream function to upload the file to s3 var uploader = new streamingS3(fileReadStream, config.aws.accessKey, config.aws.secretKey, awsHeader, options); //start […]

我应该在哪里存储我的Node.js应用程序的密钥?

我真的很困难,我应该如何隐藏我的钥匙。 我需要隐藏的两个密钥是secrets.crypto和secrets.jwt …我打算使用Elastic Beanstalk在AWS上托pipe我的应用程序。 此外,我不知道在哪里我会把我的钥匙,以访问像我的Dynamodb和我的S3桶。 exports.generateToken = (type, user) => { if (!_.isString(type)) { return undefined; } try { //Turn the json object of the current user's id and the type of token into a string var stringData = JSON.stringify({ _id: user._id, type: type }); //Take the json string and encrypt it with a secret […]

npm全局安装在弹性豆茎上

我正在遇到一个安装PM2的问题,在aws elastic beanstalk上全局安装。 我创build了以下用于安装pm2的脚本: option_settings: – option_name: NODE_ENV value: production container_commands: 01_enable_rootaccess: command: echo Defaults:root \!requiretty >> /etc/sudoers 02_install_imagemagic: command: yum install -y ImageMagick 03_download_new_relic: command: rpm -Uvh http://download.newrelic.com/pub/newrelic/el5/i386/newrelic-repo-5-3.noarch.rpm ignoreErrors: true 04_install_new_relic: command: yum install -y newrelic-sysmond ignoreErrors: true 05_add_license_key: command: /usr/sbin/nrsysmond-config –set license_key=xxxxxxx ignoreErrors: true 06_start_new_relic: command: /etc/init.d/newrelic-sysmond start ignoreErrors: true 07_install_pm2: command: sudo […]

AWS Lambda可以与外部Internet服务通话吗?

借助AWS的革命性全面pipe理function编程支持, AWS lambda可以与外部互联网/系统进行外部通信。 这个想法/动机是,如果AWS Lambda使用NodeJS SDK来提供服务PubNub,Pusher – 那么卸载实时通信的处理器方面会很好。

将AWS Lambda连接到Redshift – 在60秒后超时

我创build了一个AWS Lambda函数: 通过JDBC URLlogin到Redshift 运行一个查询 在本地,使用Node,我可以通过JDBC成功连接到Redshift实例,并执行查询。 var conString = "postgresql://USER_NAME:PASSWORD@JDBC_URL”; var client = new pg.Client(conString); client.connect(function(err) { if(err) { console.log('could not connect to redshift', err); } // omitted due to above error 但是,当我在AWS Lambda上执行该function(包装在asynchronous#瀑布块中)时,AWS Cloudwatch日志告诉我,AWS Lambdafunction在60秒后超时。 任何想法,为什么我的function无法连接?

用于创buildEMR集群的Lambda不会激发集群创build

我试图运行一个创build一个集群的λ代码,但没有任何反应,也许我误解了Node上的用法(因为我不太熟悉它)。 function如下简单: //configurationAWS Dependecies var AWS = require('aws-sdk'); exports.handler = function(event, context) { // EMR Client var emr = new AWS.EMR({apiVersion:'2009-03-31', region:'us-east-1'}); var params = {… dozens of params describing jobs …}; var AWSRequest = emr.runJobFlow(params); AWSRequest .on('success', function(response){ console.log("success => " + response)}) .on('error', function(response){ console.log("error => " + response)}) .on('complete', function(response){ console.log("complete => […]

Lambda调用callback后调出

我使用Javascript的4.3运行时使用两个lambda函数。 我运行第一个,它同步调用第二个(同步是意图)。 问题是第二次(60秒),但实际上只有22秒后才能成功完成。 以下是两个Lambda函数之间的stream程: Lamda函数我不再获取CloudWatch日志,但真正的问题(我认为)是无意中超时的函数B. 以下是一些CloudWatch日志来说明这一点: 下面包含了functionB末尾的代码 – 包括上图中的“成功”日志语句。 最初我只有callback(null, 'successful …')行,而不是nodejs 0.10.x方式,你从上下文调用succeed() 。 无奈之下,我加了两个,但结果是一样的。 任何人有一个想法是怎么回事? 我可以debugging的任何方式? 如果A和B之间的调用逻辑在B开始的状态中有所不同,则这里是调用: