Skip to content

Instantly share code, notes, and snippets.

@joaoferrao
Last active July 25, 2022 16:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joaoferrao/610482a2394b17546e12d1c172f5198e to your computer and use it in GitHub Desktop.
Save joaoferrao/610482a2394b17546e12d1c172f5198e to your computer and use it in GitHub Desktop.
caws_part_1
// TraceableRegions is a list of AWS regions we want to crawl
var TraceableRegions = [...]string{"us-east-1", "us-east-2", "us-west-1", "us-west-2", "ca-central-1", "eu-central-1", "eu-west-1", "eu-west-2", "eu-west-3", "eu-north-1", "ap-northeast-1", "ap-northeast-2", "ap-northeast-3", "ap-southeast-1", "ap-southeast-2", "ap-south-1", "sa-east-1"}
// SingleResource defines how we want to describe each AWS resource
type SingleResource struct {
Region *string
Service *string
Product *string
Details *string
ID *string
ARN *string
}
// PrettyPrintResources makes use of a nice golang library to show
// tables on stdout. Check it out: github.com/olekukonko/tablewriter
func PrettyPrintResources(resources []*SingleResource) {
var data [][]string
for _, r := range resources {
row := []string{
DerefNilPointerStrings(r.Region),
DerefNilPointerStrings(r.Service),
DerefNilPointerStrings(r.Product),
DerefNilPointerStrings(r.ID),
}
data = append(data, row)
}
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Region", "Service", "Product", "ID"})
table.SetBorder(true) // Set Border to false
table.AppendBulk(data)
table.Render()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment