aws-sdk-js

Return value from callback function in AWS Javascript SDK

落花浮王杯 提交于 2020-01-22 03:36:27
问题 I'm using the AWS Javascript SDK and I'm following the tutorial on how to send an SQS message. I'm basically following the AWS tutorial which has an example of the sendMessage as follows: sqs.sendMessage(params, function(err, data) { if (err) { console.log("Error", err); } else { console.log("Success", data.MessageId); } }); So the sendMessage function uses a callback function to output whether the operation was successful or not. Instead of printing to the console I want to return a variable

How many bits of integer data can be stored in a DynamoDB attribute of type Number?

别来无恙 提交于 2020-01-13 06:12:49
问题 DynamoDB's Number type supports 38 digits of decimal precision. This is not big enough to store a 128-bit integer which would require 39 digits. The max value is 340,282,366,920,938,463,463,374,607,431,768,211,455 for unsigned 128-bit ints or 170,141,183,460,469,231,731,687,303,715,884,105,727 for signed 128-bit ints. These are both 39-digit numbers. If I can't store 128 bits, then how many bits of integer data can I store in a Number ? 回答1: DynamoDB attribute of type Number can store 126-bit

Jest Mock Promise with Params

橙三吉。 提交于 2020-01-06 07:14:42
问题 This is the method I am trying to write Unit test in Jest async function getParameter(parameter: string, withDecryption: boolean = false): Promise<String> { const params = { Name: parameter, WithDecryption: withDecryption, }; try { const request = await ssmClient.getParameter(params).promise(); return request.Parameter.Value; } catch (err) { logger.error(`Error ${err}`); throw Error(err); } } Test Method : test('getParameterFromSystemManager', async () => { const mockedResponseData = {

Jest Mock Promise with Params

自作多情 提交于 2020-01-06 07:14:00
问题 This is the method I am trying to write Unit test in Jest async function getParameter(parameter: string, withDecryption: boolean = false): Promise<String> { const params = { Name: parameter, WithDecryption: withDecryption, }; try { const request = await ssmClient.getParameter(params).promise(); return request.Parameter.Value; } catch (err) { logger.error(`Error ${err}`); throw Error(err); } } Test Method : test('getParameterFromSystemManager', async () => { const mockedResponseData = {

JS - use files meant for <script> in Node

≯℡__Kan透↙ 提交于 2019-12-24 10:51:55
问题 I have used AWS's JS Builder (https://sdk.amazonaws.com/builder/js/) to generate a minified build of only their Lambda SDK. Now I want o use that in a NodeJS-like (specifically ReactJS) environment. Currently, I am doing so (after referring https://stackoverflow.com/a/49218103/1847976) by adding the said script in the /public/index.html and then accessing the main export (here: AWS ) via the window object (as in here window.AWS ). However, are there any issues (specifically compatibility

Unmarshalling Dynamo DB stream data to Json format

冷暖自知 提交于 2019-12-23 02:58:06
问题 I have to translate the DDB stream message into normal json type. For this I am using unmarshalleddata = aws.DynamoDB.Converter.unmarshall(result.NewImage); where result.NewImage is { carrier: { S: 'SPRING' }, partnerTransactionId: { S: 'a87ce47a46d7416586e0ece39f706d48' }, shipmentId: { S: 'SPRING2200419561404932' }, compressedShipmentPayload: { B: 'H4sIAAAAAAAAAO1b+ZPiRrL+Vzr4tb3TkrgaR7yIFWdDI3FJHHqxMSEkIQQ6aB1cjvnfX2ZVAoJur+1963hHeMaepirry8r6MisrRZd+KVhRHDu

aws-sdk (v 2.395.0) and react-native

老子叫甜甜 提交于 2019-12-11 15:35:39
问题 Am in the throes of upgrading a react native application that I've inherited responsibilities for, and am coming across some build issues after upgrading react native. I have decided to nuke the old project (based on RN 0.53.3) and created a new project with RN 0.58.2. After shoe horning the source in, my builds to simulator were getting hung up in the metro bundler at ~99%, with the application eventually timing out telling me that it Could not connect to development server. Unable to

NodeJs delay each promise within Promise.all()

非 Y 不嫁゛ 提交于 2019-12-11 07:29:26
问题 I'm trying to update a tool that was created a while ago which uses nodejs (I am not a JS developer, so I'm trying to piece the code together) and am getting stuck at the last hurdle. The new functionality will take in a swagger .json definition, compare the endpoints against the matching API Gateway on the AWS Service, using the 'aws-sdk' SDK for JS and then updates the Gateway accordingly. The code runs fine on a small definition file (about 15 endpoints) but as soon as I give it a bigger

How can I use a customized build of the AWS sdk in ReactJS?

你。 提交于 2019-12-11 06:42:49
问题 I make a customized build here of the AWS SDK: https://sdk.amazonaws.com/builder/js/ I can't find any examples of how to use this in ReactJS. Can anyone please point me in the right direction? I have tried putting this in my index.html And in my ReactJS code replaced imoprt with var: //import AWS from 'aws-sdk' var AWS = require('aws-sdk') But now my application does not even load - shows only the background image and does not load - absolutely zero shows in the Chrome console - no messages

How to configure the region in the AWS js SDK?

僤鯓⒐⒋嵵緔 提交于 2019-12-11 01:41:40
问题 My problem I am writing a simple js function that reads some information from AWS CloudWatch Logs. Following the answer at Configuring region in Node.js AWS SDK, and the AWS nodejs SDK documentation, I came up with the following: Code var AWS = require('aws-sdk'); var cloudwatchlogs = new AWS.CloudWatchLogs(); console.log(AWS.config.region) // Undefined AWS.config.region = 'eu-central-1' // Define the region with dot notation console.log(AWS.config.region) . // eu-central-1 AWS.config.update(