-
Notifications
You must be signed in to change notification settings - Fork 0
/
seed-restaurants.js
executable file
·73 lines (65 loc) · 1.86 KB
/
seed-restaurants.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const { REGION, STAGE } = process.env
const AWS = require('aws-sdk')
AWS.config.region = REGION
const dynamodb = new AWS.DynamoDB.DocumentClient()
const ssm = new AWS.SSM()
let restaurants = [
{
name: "Fangtasia",
image: "https://d2qt42rcwzspd6.cloudfront.net/manning/fangtasia.png",
themes: ["true blood"]
},
{
name: "Shoney's",
image: "https://d2qt42rcwzspd6.cloudfront.net/manning/shoney's.png",
themes: ["cartoon", "rick and morty"]
},
{
name: "Freddy's BBQ Joint",
image: "https://d2qt42rcwzspd6.cloudfront.net/manning/freddy's+bbq+joint.png",
themes: ["netflix", "house of cards"]
},
{
name: "Pizza Planet",
image: "https://d2qt42rcwzspd6.cloudfront.net/manning/pizza+planet.png",
themes: ["netflix", "toy story"]
},
{
name: "Leaky Cauldron",
image: "https://d2qt42rcwzspd6.cloudfront.net/manning/leaky+cauldron.png",
themes: ["movie", "harry potter"]
},
{
name: "Lil' Bits",
image: "https://d2qt42rcwzspd6.cloudfront.net/manning/lil+bits.png",
themes: ["cartoon", "rick and morty"]
},
{
name: "Fancy Eats",
image: "https://d2qt42rcwzspd6.cloudfront.net/manning/fancy+eats.png",
themes: ["cartoon", "rick and morty"]
},
{
name: "Don Cuco",
image: "https://d2qt42rcwzspd6.cloudfront.net/manning/don%20cuco.png",
themes: ["cartoon", "rick and morty"]
},
];
const getTableName = async () => {
return `restaurants-${STAGE}-kristo`
}
const run = async () => {
const tableName = await getTableName()
console.log(`table name: `, tableName)
let putReqs = restaurants.map(x => ({
PutRequest: {
Item: x
}
}))
const req = {
RequestItems: {}
}
req.RequestItems[tableName] = putReqs
await dynamodb.batchWrite(req).promise()
}
run().then(() => console.log("all done")).catch(err => console.error(err.message))