aws-sdk-nodejs

Async function returning pending promise, despite use of await [duplicate]

非 Y 不嫁゛ 提交于 2019-12-25 00:34:36
问题 This question already has answers here : How do I return the response from an asynchronous call? (36 answers) async/await implicitly returns promise? (4 answers) Closed 2 months ago . In the below code snippet I am trying to understand why the function does not return the result of the promise. It first logs Promise { <pending> } , then logs the response variable with the correct data from the AWS API describing the table. Why is it doing this? I've tried wrapping the function in another

s3 streaming with etags (node)

人走茶凉 提交于 2019-12-24 01:41:27
问题 We are streaming content from S3 in node using createReadStream() in aws-sdk. We would like to add etag support. If we add the 'If-None-Match' header from the client, s3 throws NotModified as an error that I can't seem to handle. retrieveFile = function(req, res) { var s3 = new AWS.S3(); var params = { Bucket: bucket, key: key }; if (req.get('If-None-Match')) { params.IfNoneMatch = req.get('If-None-Match'); } return s3.getObject(params).on('httpHeaders', function(statusCode, headers) { if

Upload Image into S3 bucket using Api Gateway, Lambda funnction

耗尽温柔 提交于 2019-12-19 08:54:06
问题 I'm trying to upload the image (base64) from the postman, I can see when I hit the Serverless API, something has been added in S3 bucket but not image, I'm using nodejs Lambda function, I tried so many solutions but that didn't work out. Please suggest me where I'm wrong: const AWS = require('aws-sdk'); const s3 = new AWS.S3(); const moment = require('moment'); const fileType = require('file-type'); const sha1 = require('sha1'); const multipart = require('parse-multipart'); exports.handler =

How to take RDS Snapshot Status as input in AWS Lambda function written in Nodejs

浪尽此生 提交于 2019-12-11 16:26:13
问题 In Params for the status variable what i have to write to take the status of snapshot as the input. Expected Output: Hello Team, The manual Snapshot of RDS Instance has Started Successfully DB Instance : mysql Region : undefined Latest Snapshot : mysql-test STARTED-TIME : 11/26/2019, 3:03:52 PM status : Creating Thanks & Regards AWS Lambda. var AWS = require('aws-sdk'); const awsConf = { region: process.env.REGION }; const rdsConfig = { apiVersion: '2014-10-31', ... awsConf }; const snsConfig

AWS CloudSearch Upload JSON: Value tag cannot be array or object

北战南征 提交于 2019-12-11 06:59:20
问题 I Am running a lambda function (NodeJS) to upload some documents to AWS Cloud Search. I keep getting the following error. { "errorMessage": "{ [\"The value of tags cannot be a JSON array or object\"] }", "errorType": "DocumentServiceException", "stackTrace": [ "Object.extractError (/var/task/node_modules/aws-sdk/lib/protocol/json.js:48:27)", "Request.extractError (/var/task/node_modules/aws-sdk/lib/protocol/rest_json.js:37:8)", "Request.callListeners (/var/task/node_modules/aws-sdk/lib

Using batchWriteItem in dynamodb

百般思念 提交于 2019-12-11 03:28:11
问题 I have two tables in my dynamo db one is candidate table and the other one is user table I want to use batchWriteItem in dynamo db in order to add the data in the table. The query which I have formatted is as follows var user = { userid: usrid, role: 'candidate', password: vucrypt.encryptpass(pass) }; var canduser = { fname: req.body.fname, lname: req.body.lname, location: req.body.location, phone: req.body.phone, ccode: req.body.ccode, grad: req.body.grad, pgrad: req.body.pgrad, ograd: req

How to pass script to UserData field in EC2 creation on AWS Lambda?

人盡茶涼 提交于 2019-12-10 20:35:39
问题 I'm trying to pass a script in Userdata field of a new EC2 instance created by an AWS Lambda (using AWS SDK for Javascript, Node.js 6.10): ... var paramsEC2 = { ImageId: 'ami-28c90151', InstanceType: 't1.micro', KeyName: 'myawesomekwy', MinCount: 1, MaxCount: 1, SecurityGroups: [groupname], UserData:'#!/bin/sh \n echo "Hello Lambda"' }; // Create the instance ec2.runInstances(paramsEC2, function(err, data) { if (err) { console.log("Could not create instance", err); return; } var instanceId =

Upload Image into S3 bucket using Api Gateway, Lambda funnction

旧城冷巷雨未停 提交于 2019-12-01 11:08:23
I'm trying to upload the image (base64) from the postman, I can see when I hit the Serverless API, something has been added in S3 bucket but not image, I'm using nodejs Lambda function, I tried so many solutions but that didn't work out. Please suggest me where I'm wrong: const AWS = require('aws-sdk'); const s3 = new AWS.S3(); const moment = require('moment'); const fileType = require('file-type'); const sha1 = require('sha1'); const multipart = require('parse-multipart'); exports.handler = function (event, context, callback) { let request = event.body; // get the request let base64String =

How to download a file from Amazon S3 bucket in node.js synchronously

穿精又带淫゛_ 提交于 2019-12-01 01:48:45
I have to download multiple files from S3 bucket using node.js. For that I have to write a for loop & call the s3.getObject(param) method to download. After the files are downloaded I have to merge their contents. I have written like this: var fileContentList = new ArrayList(); for(i=0; i<fileNameList.length i++){ s3.getObject({ Bucket: "my-bucket", Key: fileNameList.get(i) }, function (error, data) { if (error != null) { alert("Failed to retrieve an object: " + error); } else { alert("Loaded " + data.ContentLength + " bytes"); fileContentList.add(data.Body.toString()); } } ); } //Do merging

How to download a file from Amazon S3 bucket in node.js synchronously

泄露秘密 提交于 2019-11-30 21:06:40
问题 I have to download multiple files from S3 bucket using node.js. For that I have to write a for loop & call the s3.getObject(param) method to download. After the files are downloaded I have to merge their contents. I have written like this: var fileContentList = new ArrayList(); for(i=0; i<fileNameList.length i++){ s3.getObject({ Bucket: "my-bucket", Key: fileNameList.get(i) }, function (error, data) { if (error != null) { alert("Failed to retrieve an object: " + error); } else { alert("Loaded