Skip to content

Commit

Permalink
CB-9986 Fix AWS init and add new running filter types
Browse files Browse the repository at this point in the history
  • Loading branch information
Bajzathd authored and keyki committed Dec 7, 2020
1 parent 5a87618 commit 906ded5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/aws/aws-sdk-go/service/cloudformation"
"github.com/hortonworks/cloud-haunter/utils"
"net/http"
"os"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -36,6 +37,16 @@ type awsProvider struct {
}

func init() {
accessKeyId := os.Getenv("AWS_ACCESS_KEY_ID")
if len(accessKeyId) == 0 {
log.Warn("[AWS] AWS_ACCESS_KEY_ID environment variable is missing")
return
}
secretAccessKey := os.Getenv("AWS_SECRET_ACCESS_KEY")
if len(secretAccessKey) == 0 {
log.Warn("[AWS] AWS_SECRET_ACCESS_KEY environment variable is missing")
return
}
ctx.CloudProviders[types.AWS] = func() types.CloudProvider {
if len(provider.ec2Clients) == 0 {
log.Debug("[AWS] Trying to prepare")
Expand Down
15 changes: 15 additions & 0 deletions filter/running.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ func (f running) Execute(items []types.CloudItem) []types.CloudItem {
log.Debugf("[RUNNING] Filter instance, because it's not in RUNNING state: %s", item.GetName())
return false
}
case types.Stack:
if item.GetItem().(types.Stack).State != types.Running {
log.Debugf("[RUNNING] Filter stack, because it's not in RUNNING state: %s", item.GetName())
return false
}
case types.Database:
if item.GetItem().(types.Database).State != types.Running {
log.Debugf("[RUNNING] Filter database, because it's not in RUNNING state: %s", item.GetName())
return false
}
case types.Disk:
if item.GetItem().(types.Disk).State != types.Unused {
log.Debugf("[RUNNING] Filter disk, because it's in used state: %s", item.GetName())
return false
}
default:
log.Fatalf("[RUNNING] Filter does not apply for cloud item: %s", item.GetName())
}
Expand Down

0 comments on commit 906ded5

Please sign in to comment.