knownawsaccountslookup

package module
v0.0.0-...-c37ef8d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 5 Imported by: 2

README

Known AWS Accounts Lookup

This go module provides two lookup functions for the data in fwd:cloudsec's known_aws_accounts repo, which is owned and operated by the fwd:cloudsec team.

Data source of truth: https://raw.githubusercontent.com/fwdcloudsec/known_aws_accounts/main/accounts.yaml.

Functions

Examples

GetVendorNameFromAccountID
package main 

import (
	"fmt"

	"github.com/bishopfox/knownawsaccountslookup"
)

func main() {
	// Instantiate the struct
	vendors := knownawsaccountslookup.NewVendorMap()

	// Call the function to populate the struct
	vendors.PopulateKnownAWSAccounts()

	// Get the vendor name from the account ID
	vendorName := vendors.GetVendorNameFromAccountID("454464851268")
	fmt.Println(vendorName)
}

Output:

Cloudhealth
GetAccountIdsFromVendorName
package main 

import (
	"fmt"

	"github.com/bishopfox/knownawsaccountslookup"
)

func main() {
	// Instantiate the struct
	vendors := knownawsaccountslookup.NewVendorMap()

	// Call the function to populate the struct
	vendors.PopulateKnownAWSAccounts()

	// Get the account IDs from the vendor name
	accountIds := vendors.GetAccountIdsFromVendorName("Fugue")
	fmt.Println(accountIds)
}

Output:

[370134896156 944830124550]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ListOrString

type ListOrString struct {
	Values []string
}

func (*ListOrString) UnmarshalYAML

func (ls *ListOrString) UnmarshalYAML(unmarshal func(interface{}) error) error

type Vendors

type Vendors []struct {
	Name     string       `yaml:"name"`
	Source   ListOrString `yaml:"source"`
	Accounts ListOrString `yaml:"accounts"`
}

func NewVendorMap

func NewVendorMap() *Vendors

Function that uses the constructor pattern. You can use this or instantiate your struct without it.

func (*Vendors) GetAccountIdsFromVendorName

func (v *Vendors) GetAccountIdsFromVendorName(vendorName string) []string

GetAccountIdsFromVendorName retrieves the account IDs associated with a specific vendor name. It searches through the Vendors collection and returns a slice of account IDs that match the given vendor name. If no matching vendor name is found, an empty slice is returned.

func (*Vendors) GetVendorNameFromAccountID

func (v *Vendors) GetVendorNameFromAccountID(accountID string) string

GetVendorNameFromAccountID retrieves the vendor name associated with the given account ID. It searches through the Vendors collection and returns the vendor name if a matching account ID is found. If no matching account ID is found, it returns an empty string.

func (*Vendors) PopulateKnownAWSAccounts

func (v *Vendors) PopulateKnownAWSAccounts()

This function downloads the accounts.yaml file from https://raw.githubusercontent.com/fwdcloudsec/known_aws_accounts/main/accounts.yaml and populates the Vendors variable

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL