-
Notifications
You must be signed in to change notification settings - Fork 7
/
ensure_sg.go
40 lines (34 loc) · 921 Bytes
/
ensure_sg.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
package cliaws
import (
"context"
"github.com/alexflint/go-arg"
"github.com/nathants/libaws/lib"
)
func init() {
lib.Commands["ec2-ensure-sg"] = ec2EnsureSg
lib.Args["ec2-ensure-sg"] = ec2EnsureSgArgs{}
}
type ec2EnsureSgArgs struct {
VpcName string `arg:"positional,required"`
SgName string `arg:"positional,required"`
Rules []string `arg:"positional"`
Preview bool `arg:"-p,--preview"`
}
func (ec2EnsureSgArgs) Description() string {
return "\nensure a security-group\n" + `
libaws ec2-ensure-sg $vpc $sg tcp:22:0.0.0.0/0 tcp:443:0.0.0.0/0 ::sg-XXXX
`
}
func ec2EnsureSg() {
var args ec2EnsureSgArgs
arg.MustParse(&args)
ctx := context.Background()
input, err := lib.EC2EnsureSgInput("", args.VpcName, args.SgName, args.Rules)
if err != nil {
lib.Logger.Fatal("error: ", err)
}
err = lib.EC2EnsureSg(ctx, input, args.Preview)
if err != nil {
lib.Logger.Fatal("error: ", err)
}
}