How to fetch/scan all items from `AWS dynamodb` using node.js

This is working for me: export const scanTable = async (tableName) => { const params = { TableName: tableName, }; const scanResults = []; const items; do{ items = await documentClient.scan(params).promise(); items.Items.forEach((item) => scanResults.push(item)); params.ExclusiveStartKey = items.LastEvaluatedKey; }while(typeof items.LastEvaluatedKey !== “undefined”); return scanResults; };

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

Lambda functions connected to a VPC public subnet cannot typically access the internet. To access the internet from a public subnet you need a public IP or you need to route via a NAT that itself has a public IP. You also need an Internet Gateway (IGW). However: Lambda functions do not, and cannot, have … Read more

Use AWS Glue Python with NumPy and Pandas Python Packages

You can check latest python packages installed using this script as glue job import logging import pip logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) if __name__ == ‘__main__’: logger.info(pip._internal.main([‘list’])) As of 30-Jun-2020 Glue as has these python packages pre-installed. So numpy and pandas is covered. awscli 1.16.242 boto3 1.9.203 botocore 1.12.232 certifi 2020.4.5.1 chardet 3.0.4 colorama 0.3.9 docutils … Read more

AWS lambda api gateway error “Malformed Lambda proxy response”

Usually, when you see Malformed Lambda proxy response, it means your response from your Lambda function doesn’t match the format API Gateway is expecting, like this { “isBase64Encoded”: true|false, “statusCode”: httpStatusCode, “headers”: { “headerName”: “headerValue”, … }, “body”: “…” } If you are not using Lambda proxy integration, you can login to API Gateway console … Read more

Nodejs – Invoke an AWS.Lambda function from within another lambda function

Invoking a Lambda Function from within another Lambda function is quite simple using the aws-sdk which is available in every Lambda. I suggest starting with something simple first. This is the “Hello World” of intra-lambda invocation: Lambda_A invokes Lambda_B with a Payload containing a single parameter name:’Alex’. Lambda_B responds with Payload: “Hello Alex”. First create … Read more

Is there a way to change the http status codes returned by Amazon API Gateway?

Update per 20-9-2016 Amazon finally made this easy using the Lambda Proxy integration. This allows your Lambda function to return proper HTTP codes and headers: let response = { statusCode: ‘400’, body: JSON.stringify({ error: ‘you messed up!’ }), headers: { ‘Content-Type’: ‘application/json’, } }; context.succeed(response); Say goodbye request/response mapping in the API Gateway! Option 2 … Read more

AWS lambda invoke not calling another lambda function – Node.js

Note I will denote by executor the lambda that executes the second lambda. Why Timeout? Since the executor is “locked” behind a VPC – all internet communications are blocked. That results in any http(s) calls to be timed out as they request packet never gets to the destination. That is why all actions done by … Read more

API Gateway – POST multipart/form-data

API Gateway does not currently support multipart form data. This is being considered for future development. In the meantime, you will need to modify your client to use multiple requests or a single one-part request. Update: API Gateway now supports binary payloads. Simply define multipart/form-data as a binary media type for your API and proxy … Read more