Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/NERDS/basic-template/basic-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"@aws-sdk/client-dynamodb": "^3.620.0",
"@aws-sdk/lib-dynamodb": "^3.620.0",
"@aws-sdk/util-dynamodb": "^3.620.0",
"aws-sdk": "^2.1664.0",
"body-parser": "^1.20.2",
"cors": "^2.8.5",
"express": "^4.19.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"@aws-sdk/client-dynamodb": "^3.620.0",
"@aws-sdk/lib-dynamodb": "^3.620.0",
"@aws-sdk/util-dynamodb": "^3.620.0",
"aws-sdk": "^2.1664.0",
"body-parser": "^1.20.2",
"cors": "^2.8.5",
"express": "^4.19.2",
Expand Down
1 change: 0 additions & 1 deletion examples/NERDS/recipe-example/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"nanoid": "^5.0.7"
},
"devDependencies": {
"aws-sdk-client-mock": "^2.0.0",
"esbuild": "^0.14.54",
"jest": "^29.2.1"
},
Expand Down
63 changes: 0 additions & 63 deletions examples/SDK/node.js/Operations.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
//const AWS = require("aws-sdk");

//const dynamodb = new AWS.DynamoDB({ region: "us-west-2" });
const { DynamoDBClient, UpdateTableCommand, UpdateGlobalTableCommand } = require('@aws-sdk/client-dynamodb');
const { DynamoDBClient, UpdateTableCommand } = require('@aws-sdk/client-dynamodb');

const REGION = "us-west-2";
//const TABLENAME = "RetailDatabase";

async function addGlobalTableRegion() {
const params = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const AWS = require("aws-sdk");
const { DynamoDBClient, CreateGlobalTableCommand } = require("@aws-sdk/client-dynamodb");

const dynamodb = new AWS.DynamoDB({ region: "us-west-2" });
const dynamodb = new DynamoDBClient({ region: "us-west-2" });

const tableName = "Music";

Expand All @@ -15,7 +15,8 @@ async function createGlobalTable() {
],
};

const response = await dynamodb.createGlobalTable(params).promise();
const command = new CreateGlobalTableCommand(params);
const response = await dynamodb.send(command);
return response;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const AWS = require("aws-sdk");
const { DynamoDBClient, UpdateTableCommand } = require("@aws-sdk/client-dynamodb");

const dynamodb = new AWS.DynamoDB({ region: "us-west-2" });
const dynamodb = new DynamoDBClient({ region: "us-west-2" });

const tableName = "Music";

Expand All @@ -16,7 +16,8 @@ async function deleteGlobalTableRegion() {
],
};

const response = await dynamodb.updateTable(params).promise();
const command = new UpdateTableCommand(params);
const response = await dynamodb.send(command);
return response;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const AWS = require("aws-sdk");
const { DynamoDBClient, DescribeGlobalTableCommand, DescribeGlobalTableSettingsCommand } = require("@aws-sdk/client-dynamodb");

const dynamodb = new AWS.DynamoDB({ region: "us-west-2" });
const dynamodb = new DynamoDBClient({ region: "us-west-2" });

const tableName = "Music";

Expand All @@ -10,7 +10,8 @@ async function describeGlobalTable() {
GlobalTableName: tableName,
};

const response = await dynamodb.describeGlobalTable(params).promise();
const command = new DescribeGlobalTableCommand(params);
const response = await dynamodb.send(command);
return response;
}

Expand All @@ -20,7 +21,8 @@ async function describeGlobalTableSettings() {
GlobalTableName: tableName,
};

const response = await dynamodb.describeGlobalTableSettings(params).promise();
const command = new DescribeGlobalTableSettingsCommand(params);
const response = await dynamodb.send(command);
return response;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
const AWS = require("aws-sdk");
const { DynamoDBClient, DescribeTableCommand } = require("@aws-sdk/client-dynamodb");

const dynamodb = new AWS.DynamoDB({ region: "us-west-2" });
const dynamodb = new DynamoDBClient({ region: "us-west-2" });

const describeTable = async () => {
const response = await dynamodb
.describeTable({ TableName: "Music" }) // Substitute your table name for "Music"
.promise();
const command = new DescribeTableCommand({ TableName: "Music" }); // Substitute your table name for "Music"
const response = await dynamodb.send(command);

//console.log(JSON.stringify(response, null, 2));
let test = JSON.stringify(response.Table.StreamSpecification.StreamEnabled, null, 2)
console.log(test)
const streamEnabled = JSON.stringify(response.Table.StreamSpecification.StreamEnabled, null, 2)
console.log(streamEnabled);
};

describeTable().catch((error) => console.error(JSON.stringify(error, null, 2)));
Original file line number Diff line number Diff line change
@@ -1,50 +1,48 @@
const AWS = require("aws-sdk");
const {
ApplicationAutoScalingClient,
DeleteScalingPolicyCommand,
DeregisterScalableTargetCommand
} = require("@aws-sdk/client-application-auto-scaling");

const applicationAutoscaling = new AWS.ApplicationAutoScaling({
apiVersion: "2016-02-06",
const applicationAutoscaling = new ApplicationAutoScalingClient({
region: "us-west-2",
logger: console,
});

const tableName = "Music"; // Add the name of the DynamoDB table you want to add auto-scaling to between the double quotes.

const disableAutoScaling = async () => {
// Attach the Read scaling policy to the table.
let response = await applicationAutoscaling
.deleteScalingPolicy({
PolicyName: `${tableName}ScalingPolicy`,
ServiceNamespace: "dynamodb",
ResourceId: `table/${tableName}`,
ScalableDimension: "dynamodb:table:ReadCapacityUnits",
})
.promise();

response = await applicationAutoscaling
.deleteScalingPolicy({
PolicyName: `${tableName}ScalingPolicy`,
ServiceNamespace: "dynamodb",
ResourceId: `table/${tableName}`,
ScalableDimension: "dynamodb:table:WriteCapacityUnits",
})
.promise();

// Register the RCU targets for the table
response = await applicationAutoscaling
.deregisterScalableTarget({
ServiceNamespace: "dynamodb",
ResourceId: `table/${tableName}`,
ScalableDimension: "dynamodb:table:ReadCapacityUnits",
})
.promise();

// Register the RCU targets for the table
response = await applicationAutoscaling
.deregisterScalableTarget({
ServiceNamespace: "dynamodb",
ResourceId: `table/${tableName}`,
ScalableDimension: "dynamodb:table:WriteCapacityUnits",
})
.promise();
// Delete the Read scaling policy from the table.
let command = new DeleteScalingPolicyCommand({
PolicyName: `${tableName}ScalingPolicy`,
ServiceNamespace: "dynamodb",
ResourceId: `table/${tableName}`,
ScalableDimension: "dynamodb:table:ReadCapacityUnits",
});
let response = await applicationAutoscaling.send(command);

command = new DeleteScalingPolicyCommand({
PolicyName: `${tableName}ScalingPolicy`,
ServiceNamespace: "dynamodb",
ResourceId: `table/${tableName}`,
ScalableDimension: "dynamodb:table:WriteCapacityUnits",
});
response = await applicationAutoscaling.send(command);

// Deregister the RCU targets for the table
command = new DeregisterScalableTargetCommand({
ServiceNamespace: "dynamodb",
ResourceId: `table/${tableName}`,
ScalableDimension: "dynamodb:table:ReadCapacityUnits",
});
response = await applicationAutoscaling.send(command);

// Deregister the WCU targets for the table
command = new DeregisterScalableTargetCommand({
ServiceNamespace: "dynamodb",
ResourceId: `table/${tableName}`,
ScalableDimension: "dynamodb:table:WriteCapacityUnits",
});
response = await applicationAutoscaling.send(command);

console.log("Autoscaling has been disabled");
};
Expand Down
Loading