amazon-dynamodb

How to determine if a DynamoDB item was indeed deleted?

半城伤御伤魂 提交于 2021-02-07 02:00:25
问题 DynamoDB provides an API for deleting items. In the returned DeleteItemOutcome and DeleteItemResult there is no field or method to determine if the key was found and the item was indeed deleted. The only way to find out if the item was indeed present and deleted, is to request the items' attributes: new DeleteItemSpec() .withPrimaryKey("key","1") .withReturnValues(ReturnValue.ALL_OLD)) This, however, consumes extra read capacity. Is there a more efficient way to check the delete result - key

How to update an item in Dynamodb of type String Set (SS)?

谁都会走 提交于 2021-02-06 15:49:36
问题 I have created a attribute of type String Set. When I create the Item and assign an attribute of type SS everything works. But when I try to update this attribute, the data type changes to a list ("L"). I try this: qw = new AWS.DynamoDB.DocumentClient(); var params = { TableName : "myTable", Key: { "id": somekey }, UpdateExpression: "set ssvar= :arrp", ExpressionAttributeValues: { ":arrp": [ "test", "test2" ] } }; qw.update (etc.) This leads to a change in datatype in dynamodb and in stead of

How do I define resources for iamrolestatements for multiple dynamodb tables in serverless framework?

馋奶兔 提交于 2021-02-06 15:15:39
问题 I want to use more than one dynamodb table in my serverless project. How do I properly define multiple resources in the iamrolestatements? I have an example serverless.yml service: serverless-expense-tracker frameworkVersion: ">=1.1.0 <2.0.0" provider: name: aws runtime: nodejs6.10 environment: EXPENSES_TABLE: "${self:service}-${opt:stage, self:provider.stage}-expenses" BUDGETS_TABLE: "${self:service}-${opt:stage, self:provider.stage}-budgets" iamRoleStatements: - Effect: Allow Action: -

Migration details for DynamoDB v2 in AWS Java SDK?

回眸只為那壹抹淺笑 提交于 2021-02-05 20:11:31
问题 Has anyone made the change to the new namespaces ( com.amazonaws.services.dynamodbv2 ) and interfaces for DynamoDB in the AWS Java SDK 1.4.2 (and later)? The release of Local Secondary Indices apparently necessitated breaking changes as per the 1.4.2 release notes. Has anyone found a guide detailing what changed and what needs to happen to migrate existing code? I am trying to decide when is best to make this change for an existing code base. 回答1: The new dynamodbv2 namespace of DynamoDB

Migration details for DynamoDB v2 in AWS Java SDK?

雨燕双飞 提交于 2021-02-05 20:10:56
问题 Has anyone made the change to the new namespaces ( com.amazonaws.services.dynamodbv2 ) and interfaces for DynamoDB in the AWS Java SDK 1.4.2 (and later)? The release of Local Secondary Indices apparently necessitated breaking changes as per the 1.4.2 release notes. Has anyone found a guide detailing what changed and what needs to happen to migrate existing code? I am trying to decide when is best to make this change for an existing code base. 回答1: The new dynamodbv2 namespace of DynamoDB

How to check whether an attribute is not present in dynamoDB filter expression

此生再无相见时 提交于 2021-01-29 22:52:07
问题 I am introducing a new field InActive in my dynamo DB table, now I want to fetch the records which were active earlier (assuming all previous records were active) along with new Active records. What should be my dynamo DB Query expression? final HashMap<String, AttributeValue> activeExpressionAttrValue = new HashMap<>(); activeExpressionAttrValue.put(":in_active_false", new AttributeValue().withBOOL(false)); activeExpressionAttrValue.put(":in_active_null", new AttributeValue().withNULL(true))

How to check whether an attribute is not present in dynamoDB filter expression

狂风中的少年 提交于 2021-01-29 22:39:51
问题 I am introducing a new field InActive in my dynamo DB table, now I want to fetch the records which were active earlier (assuming all previous records were active) along with new Active records. What should be my dynamo DB Query expression? final HashMap<String, AttributeValue> activeExpressionAttrValue = new HashMap<>(); activeExpressionAttrValue.put(":in_active_false", new AttributeValue().withBOOL(false)); activeExpressionAttrValue.put(":in_active_null", new AttributeValue().withNULL(true))

Pytest - How to Parameterize tests with multiple scenarios?

倾然丶 夕夏残阳落幕 提交于 2021-01-29 17:55:28
问题 I'm using pytest ,boto3 and aws and want to have dynamic assertions with parameterized tests. How to improve this code to only assert on a specific group of subnetids? production_private_ids = ["subnet-08f6d70b65b5cxx38", "subnet-0b6aaaf1ce207xx03", "subnet-0e54fda8f811fxxd8"]) .... nonproduction_private_ids = ["subnet-11f6xx0b65b5cxx38", "subnet-116aaaf1ce207xx99", "subnet-11xxfda8f811fxx77"]) .... @pytest.mark.parametrize("subnet", ["production_private_ids", "nonproduction_private_ids",

Updating the value of DynamoDB table with boto3 implemented lambda function

给你一囗甜甜゛ 提交于 2021-01-29 10:13:02
问题 I am trying to achieve an update operation using my API method to update the content of the table. I have following lambda code set up: def lambda_handler(event, context): param = event['queryStringParameters']['employeID'] name = event['queryStringParameters']['employeName'] dynamodb = boto3.resource('dynamodb', region_name="us-east-1") table = dynamodb.Table('api_demo_employe') response = table.update_item( Key = { 'employeID' : param } ) I need to figure out how can i set the

How to return from nested function in Node.js?

痴心易碎 提交于 2021-01-29 06:09:06
问题 I'm wrapping my dynamoDB function into another function and I'm having issues with returning it to the "item" const. What I'm missing here? Works: const params = { TableName: table, Key: { id: id }, }; dynamoDb.get(params, (error, result) => { if (error) { console.error(error); callback(null, { statusCode: error.statusCode || 501, body: 'Couldn\'t fetch the item.', }); return; } const item = result.Item }) Doesn't work (returns undefinied): const getFromDb = () => { const params = { TableName