Last active
July 25, 2022 16:33
-
-
Save joaoferrao/610482a2394b17546e12d1c172f5198e to your computer and use it in GitHub Desktop.
caws_part_1
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
// 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