-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcfn.go
43 lines (39 loc) · 1.23 KB
/
cfn.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
package main
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/awslabs/aws-sdk-go/service/cloudformation"
"log"
)
func listCfn(region string, verbose bool) (cfnNumber int) {
svc := cloudformation.New(session.New(&aws.Config{Region: aws.String(region)}))
params := &cloudformation.ListStacksInput{
StackStatusFilter: []*string{
aws.String("CREATE_COMPLETE"),
aws.String("CREATE_FAILED"),
aws.String("CREATE_IN_PROGRESS"),
aws.String("DELETE_FAILED"),
aws.String("DELETE_IN_PROGRESS"),
aws.String("ROLLBACK_FAILED"),
aws.String("ROLLBACK_IN_PROGRESS"),
aws.String("UPDATE_COMPLETE"),
aws.String("UPDATE_COMPLETE_CLEANUP_IN_PROGRESS"),
aws.String("UPDATE_IN_PROGRESS"),
aws.String("UPDATE_ROLLBACK_COMPLETE"),
aws.String("UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS"),
aws.String("UPDATE_ROLLBACK_FAILED"),
aws.String("UPDATE_ROLLBACK_IN_PROGRESS"),
},
}
resp, err := svc.ListStacks(params)
if err != nil {
log.Fatal("Cannot get CFN data: ", err)
}
if verbose {
for _, name := range resp.StackSummaries {
log.Println("CFN Stack Name: ", *name.StackName, " Status: ", *name.StackStatus)
}
}
cfnNumber = len(resp.StackSummaries)
return cfnNumber
}