-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
86 lines (74 loc) · 1.53 KB
/
main.go
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
74
75
76
77
78
79
80
81
82
83
84
85
86
package main
import "log"
func main() {
client, err := GetHuaweiClient()
if err != nil {
log.Print(err)
return
}
config, err := parseConfig()
if err != nil {
log.Print(err)
return
}
//create network
vpcId, err := CreateVpc(client, config)
if err != nil {
log.Print(err)
return
}
networkId, subnetId, err := CreateSubnet(client, config, vpcId)
if err != nil {
log.Print(err)
return
}
securityGroupIds, err := CreateSecurityGroup(client, config)
if err != nil {
log.Print(err)
return
}
//create server
instance, err := CreateEcs(client, config, vpcId, networkId, securityGroupIds)
if err != nil {
log.Print(err)
return
}
//create loadBalancer
elbId, err := CreateElb(client, subnetId, vpcId, config)
if err != nil {
log.Print(err)
return
}
listener80, err := CreateListener(client, elbId, 80)
if err != nil {
log.Print(err)
return
}
listener443, err := CreateListener(client, elbId, 443)
if err != nil {
log.Print(err)
return
}
pool80, err := CreatePool(client, listener80, vpcId)
if err != nil {
log.Print(err)
return
}
pool443, err := CreatePool(client, listener443, vpcId)
if err != nil {
log.Print(err)
return
}
elbPools := make([]HuaweiElbPool, 0)
elbPools = append(elbPools, HuaweiElbPool{Id: pool80, Port: 80})
elbPools = append(elbPools, HuaweiElbPool{Id: pool443, Port: 443})
err = AddServerToElb(client, subnetId, elbPools, instance)
if err != nil {
log.Print(err)
return
}
err = CreateNat(client, config, vpcId, networkId)
if err != nil {
return
}
}