Remove /cloud from readme.
@@ -45,16 +45,23 @@ for (let i = 0; i < 3; i++) {
Or a simple serverless timer that archives Hacker News every day at 8:30AM:
```typescript
-const cloud = require("@pulumi/cloud");
-const snapshots = new cloud.Table("snapshots");
-cloud.timer.daily("daily-yc-snapshot", { hourUTC: 8, minuteUTC: 30 }, () => {
- const req = require("https").get("https://news.ycombinator.com", res => {
+const aws = require("@pulumi/aws");
+
+const snapshots = new aws.dynamodb.Table("snapshots", {
+ attributes: [{ name: "id", type: "S", }],
+ hashKey: "id", billingMode: "PAY_PER_REQUEST",
+});
+
+aws.cloudwatch.onSchedule("daily-yc-snapshot", "cron(30 8 * * ? *)", () => {
+ require("https").get("https://news.ycombinator.com", res => {
let content = "";
res.setEncoding("utf8");
res.on("data", chunk => content += chunk);
- res.on("end", () => snapshots.insert({ date: Date.now(), content }));
- });
- req.end();
+ res.on("end", () => new aws.sdk.DynamoDB.DocumentClient().put({
+ TableName: snapshots.name.get(),
+ Item: { date: Date.now(), content },
+ }).promise());
+ }).end();
});
```
