Hello! Looking for AWS examples to: 1. Create Dyna...
# general
b
Hello! Looking for AWS examples to: 1. Create Dynamodb with autoscaling 2. Attaching a Lambda to listen for stream events
w
I think I have some code which does exactly both of these that I was working on recently - let me find it...
b
thank u!
w
Turns out the example I had wasn't quite this scenario - but here's a smaller example that includes both:
Copy code
let updateTable = new aws.dynamodb.Table("updates", {
    attributes: [{ name: "stackId", type: "S" }, { name: "taskId", type: "S" }],
    hashKey: "stackId",
    rangeKey: "taskId",
    billingMode: "PAY_PER_REQUEST",
});

updateTable.onEvent("", async (ev) => {
    console.log(JSON.stringify(ev));
}, { startingPosition: "TRIM_HORIZON" });
b
thank u! so the autoscaling is set with PAY_PER_REQUEST?
w
Yeah - it’s a strange API decision, but that’s what they did in the raw API and CloudFormation as well.
b
what if u wanted autoscaling with an initial read/write provision? and how to specifiy the target %?
w
Oh - actually - i interpreted “autoscaling” as meaning the “on-demand”; https://aws.amazon.com/blogs/aws/amazon-dynamodb-on-demand-no-capacity-planning-and-pay-per-request-pricing/ If you want pre-provisioned but with autoscaling that is meaningfully more complex to setup - but possible.
b
Thanks for this for Luke! I'm testing a solution that creates a new
aws.appautoscaling.Policy
type. I'll let you know if it works 🙂