forked from imjerrybao/apex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
infra.go
51 lines (40 loc) · 931 Bytes
/
infra.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
// Package infra proxies Terraform commands.
package infra
import (
"strings"
"github.com/spf13/cobra"
"github.com/apex/apex/cmd/apex/root"
"github.com/apex/apex/infra"
)
// example output.
const example = ` View change plan
$ apex infra plan
Apply changes
$ apex infra apply`
// Command config.
var Command = &cobra.Command{
Use: "infra",
Short: "Infrastructure management",
Example: example,
RunE: run,
}
// Initialize.
func init() {
root.Register(Command)
}
// Run command.
func run(c *cobra.Command, args []string) error {
err := root.Project.LoadFunctions()
// Hack to prevent initial `apex infra apply` from failing,
// as we load functions to expose their ARNs.
if err != nil {
if !strings.Contains(err.Error(), "Role: zero value") {
return err
}
}
p := &infra.Proxy{
Functions: root.Project.Functions,
Region: *root.Session.Config.Region,
}
return p.Run(args...)
}