-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from mlafeldt/wipe-state
Allow to wipe state of Chaos Monkey
- Loading branch information
Showing
3 changed files
with
65 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"sort" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/autoscaling" | ||
"github.com/aws/aws-sdk-go/service/simpledb" | ||
) | ||
|
||
func autoScalingGroups() ([]string, error) { | ||
var groups []string | ||
svc := autoscaling.New(session.New()) | ||
err := svc.DescribeAutoScalingGroupsPages(nil, func(out *autoscaling.DescribeAutoScalingGroupsOutput, last bool) bool { | ||
for _, g := range out.AutoScalingGroups { | ||
groups = append(groups, aws.StringValue(g.AutoScalingGroupName)) | ||
} | ||
return !last | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
sort.Strings(groups) | ||
return groups, nil | ||
} | ||
|
||
func deleteSimpleDBDomain(domainName string) error { | ||
var domainExists bool | ||
svc := simpledb.New(session.New()) | ||
err := svc.ListDomainsPages(nil, func(out *simpledb.ListDomainsOutput, last bool) bool { | ||
for _, n := range out.DomainNames { | ||
if aws.StringValue(n) == domainName { | ||
domainExists = true | ||
} | ||
} | ||
return !last | ||
}) | ||
if !domainExists { | ||
return fmt.Errorf("SimpleDB domain %q does not exist", domainName) | ||
} | ||
_, err = svc.DeleteDomain(&simpledb.DeleteDomainInput{ | ||
DomainName: aws.String(domainName), | ||
}) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters