blob: 55e04177c6e010fcc0e0c1721b1e8808f1f14ef5 (
plain)
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
|
package main
// TODO: set up iam role and policy needed for ec2 instances to access this stuff;
// see arn:aws:iam::557852942063:policy/pipelinestorageandqueue
// and arn:aws:iam::557852942063:role/pipeliner
// TODO: set up launch template for ec2 instances
import (
"log"
"os"
"rescribe.xyz/bookpipeline"
)
type MkPipeliner interface {
MinimalInit() error
CreateBucket(string) error
CreateQueue(string) error
}
func main() {
if len(os.Args) != 1 {
log.Fatal("Usage: mkpipeline\n\nSets up necessary buckets and queues for our cloud pipeline\n")
}
var conn MkPipeliner
conn = &bookpipeline.AwsConn{Region: "eu-west-2", Logger: log.New(os.Stdout, "", 0)}
err := conn.MinimalInit()
if err != nil {
log.Fatalln("Failed to set up cloud connection:", err)
}
prefix := "rescribe"
buckets := []string{"inprogress", "done"}
queues := []string{"preprocess", "wipeonly", "ocr", "analyse", "ocrpage"}
for _, bucket := range buckets {
bname := prefix + bucket
log.Printf("Creating bucket %s\n", bname)
err = conn.CreateBucket(bname)
if err != nil {
log.Fatalln(err)
}
}
for _, queue := range queues {
qname := prefix + queue
log.Printf("Creating queue %s\n", qname)
err = conn.CreateQueue(qname)
if err != nil {
log.Fatalln(err)
}
}
}
|