https://pulumi.com logo
b

brainy-magician-83981

01/22/2019, 10:19 PM
Hello! Looking for AWS examples to: 1. Create Dynamodb with autoscaling 2. Attaching a Lambda to listen for stream events
w

white-balloon-205

01/22/2019, 10:20 PM
I think I have some code which does exactly both of these that I was working on recently - let me find it...
b

brainy-magician-83981

01/22/2019, 10:20 PM
thank u!
w

white-balloon-205

01/22/2019, 11:09 PM
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

brainy-magician-83981

01/22/2019, 11:12 PM
thank u! so the autoscaling is set with PAY_PER_REQUEST?
w

white-balloon-205

01/22/2019, 11:13 PM
Yeah - it’s a strange API decision, but that’s what they did in the raw API and CloudFormation as well.
b

brainy-magician-83981

01/22/2019, 11:14 PM
what if u wanted autoscaling with an initial read/write provision? and how to specifiy the target %?
w

white-balloon-205

01/22/2019, 11:15 PM
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

brainy-magician-83981

01/23/2019, 4:46 AM
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 🙂