All Questions
Tagged with node.js amazon-web-services
8,407
questions
459
votes
22
answers
307k
views
Can an AWS Lambda function call another
I have 2 Lambda functions - one that produces a quote and one that turns a quote into an order.
I'd like the Order lambda function to call the Quote function to regenerate the quote, rather than just ...
332
votes
21
answers
229k
views
How to yum install Node.JS on Amazon Linux
I've seen the writeup on using yum to install the dependencies, and then installing Node.JS & NPM from source. While this does work, I feel like Node.JS and NPM should both be in a public repo ...
195
votes
19
answers
179k
views
Configuring region in Node.js AWS SDK
Can someone explain how to fix a missing config error with Node.js? I've followed all the examples from the aws doc page but I still get this error no matter what.
{ [ConfigError: Missing region in ...
184
votes
9
answers
146k
views
Nodejs AWS SDK S3 Generate Presigned URL
I am using the NodeJS AWS SDK to generate a presigned S3 URL. The docs give an example of generating a presigned URL.
Here is my exact code (with sensitive info omitted):
const AWS = require('aws-...
162
votes
14
answers
171k
views
Pipe a stream to s3.upload()
I'm currently making use of a node.js plugin called s3-upload-stream to stream very large files to Amazon S3. It uses the multipart API and for the most part it works very well.
However, this module ...
147
votes
19
answers
112k
views
AWS lambda api gateway error "Malformed Lambda proxy response"
I am trying to set up a hello world example with AWS lambda and serving it through api gateway. I clicked the "Create a Lambda Function", which set up the api gatway and selected the Blank Function ...
127
votes
11
answers
202k
views
AccessDeniedException: User is not authorized to perform: lambda:InvokeFunction
I'm trying to invoke a lambda function from node.
var aws = require('aws-sdk');
var lambda = new aws.Lambda({
accessKeyId: 'id',
secretAccessKey: 'key',
region: 'us-west-2'
});
lambda....
126
votes
11
answers
111k
views
How to determine if object exists AWS S3 Node.JS sdk
I need to check if a file exists using AWS SDK. Here is what I'm doing:
var params = {
Bucket: config.get('s3bucket'),
Key: path
};
s3.getSignedUrl('getObject', params, callback);
It works ...
115
votes
11
answers
232k
views
Read file from aws s3 bucket using node fs
I am attempting to read a file that is in a aws s3 bucket using
fs.readFile(file, function (err, contents) {
var myLines = contents.Body.toString().split('\n')
})
I've been able to download and ...
115
votes
10
answers
174k
views
Why is this HTTP request not working on AWS Lambda?
I'm getting started with AWS Lambda and I'm trying to request an external service from my handler function. According to this answer, HTTP requests should work just fine, and I haven't found any ...
114
votes
5
answers
144k
views
Nodejs - Invoke an AWS.Lambda function from within another lambda function
I have the following function which I use to invoke a Lambda function from within my code.
However when I try to use it within a Lambda function, I get the following error:
AWS lambda undefined 0....
106
votes
9
answers
97k
views
AWS Lambda Error: "Cannot find module '/var/task/index'"
Node.js Alexa Task Issue
I'm currently coding a Node.js Alexa Task via AWS Lambda, and I have been trying to code a function that receives information from the OpenWeather API and parses it into a ...
106
votes
6
answers
279k
views
How enable access to AWS STS AssumeRole
I am getting an error when calling to assume role method of STS. It says that the user is not authorized to perform sts:AsumeRole on resource xxx.
I did the following:
I created a role to access to ...
100
votes
18
answers
239k
views
Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
When I am trying to load AWS credentials in my project it gives back an error.
When using credentials in plain text everything works good but when I am trying to use environment variables it's not ...
90
votes
13
answers
243k
views
Install node in Dockerfile?
I am user of AWS elastic beanstalk, and I have a little problem. I want to build my CSS files with less+node. But I don`t know how to install node in my dockerfile, when building with jenkins.
Here ...
88
votes
3
answers
67k
views
AWS S3 node.js SDK uploaded file and folder permissions
I'm uploading file to S3 using aws-sdk package:
fs.readFile(sourceFile, function (err, data) {
if (err) { throw err; }
s3.client.putObject({
Bucket: bucketName,
Key: 'Folder/...
87
votes
8
answers
134k
views
NodeJS How do I Download a file to disk from an aws s3 bucket?
My goal:
Display a dialog box prompting the user to save a file being downloaded from aws.
My problem:
I am currently using awssum-amazon-s3 to create a download stream. However I've only managed ...
84
votes
7
answers
81k
views
How can I retrieve a user's public IP address via Amazon API Gateway + Lambda (node)
I'm currently writing a Node.js lambda function, in which I want to log the incoming requester's public IP address. I've been looking through both the API Gateway and Lambda docs all day, but haven't ...
79
votes
15
answers
61k
views
How can I delete folder on s3 with node.js?
Yes, I know. There is no folder concept on s3 storage. but I really want to delete a specific folder from s3 with node.js. I tried two solutions, but both didn't work.
My code is below:
Solution 1:
...
79
votes
5
answers
141k
views
Query condition missed key schema element : Validation Error
I am trying to query dynamodb using the following code:
const AWS = require('aws-sdk');
let dynamo = new AWS.DynamoDB.DocumentClient({
service: new AWS.DynamoDB(
{
apiVersion: "2012-08-...
78
votes
12
answers
130k
views
Installing NPM on AWS EC2
Working on Ec2 on AWS.
I have installed Node.js and it works fine.
But the problem arises when trying to install npm.
I am using the following command to install it:
sudo curl http://npmjs.org/...
75
votes
4
answers
100k
views
Upload a binary file to S3 using AWS SDK for Node.js
Update: For future reference, Amazon have now updated the documentation from what was there at time of asking. As per @Loren Segal's comment below:-
We've corrected the docs in the latest preview ...
71
votes
4
answers
86k
views
How do you query for a non-existent (null) attribute in DynamoDB
I'm trying to query a DynamoDB table to find all items where the email attribute is not set. A global secondary index called EmailPasswordIndex exists on the table which includes the email field.
...
69
votes
7
answers
100k
views
How to wait for async actions inside AWS Lambda?
I am trying to process uploaded file in S3. Since getObject is asyncronous main function ends before processing is done, and AWS kills lambda in 3-4 seconds.
Even worse, processing method also has ...
68
votes
3
answers
30k
views
How to deploy a React + NodeJS Express application to AWS?
I have a React + Webpack/Babel + Node/Express application and I want to deploy it on AWS.
Would I have to deploy React and Node/Express separately? Or could they be deployed together at once?
67
votes
6
answers
106k
views
AWS S3 object listing
I am using aws-sdk using node.js. I want to list images in specified folder e.g.
I want to list all files and folder in this location but not folder (images) content. There is list Object function in ...
63
votes
11
answers
28k
views
MongoDB connections from AWS Lambda
I'm looking to create a RESTful API using AWS Lambda/API Gateway connected to a MongoDB database. I've read that connections to MongoDB are relatively expensive so it's best practice to retain a ...
61
votes
7
answers
33k
views
'exec user process caused: exec format error' in AWS Fargate Service
I am totally new to AWS but I've been running my dockerized application locally for months now with no issues. Now that I am trying to deploy this app via AWS ECS/Fargate, my containers are stopped ...
60
votes
3
answers
45k
views
What is partition key in AWS Kinesis all about?
I was reading about AWS Kinesis. In the following program, I write data into the stream named TestStream. I ran this piece of code 10 times, inserting 10 records into the stream.
var params = {
...
60
votes
1
answer
30k
views
Append a new object to a JSON Array in DynamoDB using NodeJS
I am using a JSON structure to store details of a person. Basically name, phone, registeredTimestamp etc., will be other attributes, and Primary key will be the email address.
markedLocations, ...
59
votes
2
answers
57k
views
Scan Function in DynamoDB with reserved keyword as FilterExpression NodeJS
My scan function :
var tableName = 'faasos_orders',
filterExp = 'status = :delivered OR status = :void OR status = :bad',
projectionValues = '',
expressionAttr = {};
...
58
votes
7
answers
111k
views
AWS Missing credentials when I try send something to my S3 Bucket (Node.js)
I'm having this issue since yesterday, and I'm having trouble for find a solution.
I'm trying to send somethings to my S3 bucket, but this message appear in my console when I try:
{ [CredentialsError: ...
58
votes
8
answers
32k
views
502 Bad Gateway Deploying Express Generator Template on Elastic Beanstalk
I used the express generator to create a simple express app, which when started on dev works fine on localhost:3000.
When I push this to elastic beanstalk using the eb command-- git aws.push, however,...
57
votes
5
answers
87k
views
How to create folder or key on s3 using AWS SDK for Node.js?
I'm using AWS SDK for Node.js to create a folder or key on s3. I searched on google, but I got nothing. Does anybody know how can I create a folder under my bucket with AWS SDK for Node.js?
and how ...
57
votes
5
answers
20k
views
AWS Lambda: How to store secret to external API?
I'm building a monitoring tool based on AWS Lambda. Given a set of metrics, the Lambdas should be able to send SMS using Twilio API. To be able to use the API, Twilio provide an account SID and an ...
56
votes
5
answers
29k
views
avoid rebuilding node_modules in elastic beanstalk
We have a fairly simple node.js app, but due to AWS Elastic Beanstalk deployment mechanism, it takes about 5 minutes to roll-out a new version (via git aws.push) even after a single file commit.
I.e. ...
55
votes
6
answers
76k
views
How to copy/move all objects in Amazon S3 from one prefix to other using the AWS SDK for Node.js
How do I copy all objects from one prefix to other? I have tried all possible ways to copy all objects in one shot from one prefix to other, but the only way that seems to work is by looping over a ...
55
votes
3
answers
76k
views
How do you write to the file system of an aws lambda instance?
I am unsuccessfully trying to write to the file system of an aws lambda instance. The docs say that a standard lambda instance has 512mb of space available at /tmp/. However the following code that ...
53
votes
9
answers
101k
views
node.js AWS dynamodb updateItem
Is there a way to achieve the following few points with updateItem:
Add attributes if the attributes not exist in DynamoDB
Update attributes if the attributes exist in DynamoDB
Leave those attributes ...
53
votes
7
answers
64k
views
Creating a lambda function in AWS from zip file
I am trying to create a simple lambda function, and I'm running into an error.
My code is basically
console.log('Loading function');
exports.handler = function(event, context) {
console.log('...
53
votes
5
answers
87k
views
User is not authorized to perform: dynamodb:PutItem on resource
I am trying to access DynamoDB from my Node app deployed on AWS ElasticBeanStalk. I am getting an error
User is not authorized to perform: dynamodb:PutItem on resource
It works perfectly fine locally,...
52
votes
9
answers
41k
views
How to change Node Version in Provision Step in Amplify Console
I'm facing the problem that I cant build my Angular app through the AWS Amplify Console:
"You are running version v8.12.0 of Node.js, which is not supported by Angular CLI 8.0+.
The official Node....
52
votes
13
answers
109k
views
S3 Bucket Lambda Event: Unable to validate the following destination configurations
I'm trying to create an S3 bucket and immediately assign a lambda notification event to it.
Here's the node test script I wrote:
const aws = require('aws-sdk');
const uuidv4 = require('uuid/v4');
...
51
votes
6
answers
50k
views
Upload files to a specific folder in the bucket with AWS SDK
I'm uploading images to AWS S3 with the developer toolkit for node:
const aws = require('aws-sdk');
const s3Bucket = process.env.S3_BUCKET;
const s3 = new aws.S3({
signatureVersion: 'v4',
...
51
votes
5
answers
80k
views
How to get the URL of a file on AWS S3 using aws-sdk?
I'm using an AWS Lambda function to create a file and save it to my bucket on S3, it is working fine. After executing the putObject method, I get a data object, but it only contains an Etag of the ...
51
votes
5
answers
58k
views
s3.getObject().createReadStream() : How to catch the error?
I am trying to write a program to get a zip file from s3, unzip it, then upload it to S3.
But I found two exceptions that I can not catch.
1. StreamContentLengthMismatch: Stream content length ...
51
votes
8
answers
60k
views
How can I automatically start a node.js application in Amazon Linux AMI on aws?
Is there a brief guide to explain how to start up a application when the instance starts up and running? If it were one of the services installed through yum then I guess I can use /sbin/chkconfig to ...
49
votes
14
answers
109k
views
aws-lambda Cannot find module
I keep getting this error in the aws-lambda console when uploading code from a zip file. I have tried uploading other zip files and they work correctly. The .js file is named "CreateThumbnail.js" in ...
47
votes
5
answers
57k
views
using profile that assume role in aws-sdk (AWS JavaScript SDK)
Using the AWS SDK for JavaScript, I want to use a default profile that assumes the a role. This works perfectly with the AWS CLI. Using node.js with the SDK does not assume the role, but only uses ...
47
votes
11
answers
119k
views
"Could not load credentials from any providers" while using dynamodb locally in Node
im setting up a dynamodb locally to test with my Node app. To set it up i just plain out copied the code from here and adjusted it for my needs. This is the code:
var AWS = require("aws-sdk");
var ...