aws

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GlobalRegion  string = "global"
	DefaultRegion string = "us-east-1"
)
View Source
const Global = "global"

Variables

View Source
var GovCloudRegions = []string{
	"us-gov-east-1",
	"us-gov-west-1",
}

GovCloudRegions contains all of the U.S. GovCloud regions. In accounts with GovCloud enabled, these are the only available regions.

View Source
var OptInNotRequiredRegions = []string{
	"eu-north-1",
	"ap-south-1",
	"eu-west-3",
	"eu-west-2",
	"eu-west-1",
	"ap-northeast-3",
	"ap-northeast-2",
	"ap-northeast-1",
	"sa-east-1",
	"ca-central-1",
	"ap-southeast-1",
	"ap-southeast-2",
	"eu-central-1",
	"us-east-1",
	"us-east-2",
	"us-west-1",
	"us-west-2",
}

OptInNotRequiredRegions contains all regions that are enabled by default on new AWS accounts Beginning in Spring 2019, AWS requires new regions to be explicitly enabled See https://aws.amazon.com/blogs/security/setting-permissions-to-enable-accounts-for-upcoming-aws-regions/

Functions

func GetEnabledRegions

func GetEnabledRegions() ([]string, error)

GetEnabledRegions - Get all regions that are enabled (DescribeRegions excludes those not enabled by default)

func GetTargetRegions

func GetTargetRegions(enabledRegions []string, selectedRegions []string, excludedRegions []string) ([]string, error)

GetTargetRegions - Used enabled, selected and excluded regions to create a final list of valid regions

func HandleResourceTypeSelections

func HandleResourceTypeSelections(
	includeResourceTypes, excludeResourceTypes []string,
) ([]string, error)

HandleResourceTypeSelections accepts a slice of target resourceTypes and a slice of resourceTypes to exclude. It filters any excluded or invalid types from target resourceTypes then returns the filtered slice

func IsNukeable

func IsNukeable(resourceType string, resourceTypes []string) bool

IsNukeable - Checks if we should nuke a resource or not

func IsValidResourceType

func IsValidResourceType(resourceType string, allResourceTypes []string) bool

IsValidResourceType - Checks if a resourceType is valid or not

func ListResourceTypes

func ListResourceTypes() []string

ListResourceTypes - Returns list of resources which can be passed to --resource-type

func NewSession

func NewSession(region string) *session.Session

func NukeAllResources

func NukeAllResources(account *AwsAccountResources, regions []string) error

NukeAllResources - Nukes all aws resources

Types

type AwsAccountResources

type AwsAccountResources struct {
	Resources map[string]AwsRegionResource
}

func GetAllResources

func GetAllResources(c context.Context, query *Query, configObj config.Config) (*AwsAccountResources, error)

GetAllResources - Lists all aws resources

func (*AwsAccountResources) GetRegion

func (a *AwsAccountResources) GetRegion(region string) AwsRegionResource

func (*AwsAccountResources) TotalResourceCount

func (a *AwsAccountResources) TotalResourceCount() int

TotalResourceCount returns the number of resources found, that are eligible for nuking, across all AWS regions targeted In other words, if you have 3 nukeable resources in us-east-1 and 4 nukeable resources in ap-southeast-1, this function would return 7

type AwsRegionResource

type AwsRegionResource struct {
	Resources []*AwsResources
}

func (*AwsRegionResource) CountOfResourceType

func (arr *AwsRegionResource) CountOfResourceType(resourceType string) int

CountOfResourceType is a convenience method that returns the number of the supplied resource type found in the AwsRegionResource

func (*AwsRegionResource) IdentifiersForResourceType

func (arr *AwsRegionResource) IdentifiersForResourceType(resourceType string) []string

IdentifiersForResourceType is a convenience method that returns the list of resource identifiers for a given resource type, if available

func (*AwsRegionResource) MapResourceNameToIdentifiers

func (arr *AwsRegionResource) MapResourceNameToIdentifiers() map[string][]string

MapResourceNameToIdentifiers converts a slice of Resources to a map of resource types to their found identifiers For example: ["ec2"] = ["i-0b22a22eec53b9321", "i-0e22a22yec53b9456"]

func (*AwsRegionResource) ResourceTypePresent

func (arr *AwsRegionResource) ResourceTypePresent(resourceType string) bool

ResourceTypePresent is a convenience method that returns true, if the given resource is found in the AwsRegionResource, or false if it is not

type AwsResources

type AwsResources interface {
	Init(session *session.Session)
	ResourceName() string
	ResourceIdentifiers() []string
	MaxBatchSize() int
	Nuke(identifiers []string) error
	GetAndSetIdentifiers(c context.Context, configObj config.Config) ([]string, error)
}

func GetAllRegisteredResources

func GetAllRegisteredResources() []*AwsResources

GetAllRegisteredResources - returns a list of all registered resources without initialization. This is useful for listing all resources without initializing them.

func GetAndInitRegisteredResources

func GetAndInitRegisteredResources(session *session.Session, region string) []*AwsResources

GetAndInitRegisteredResources - returns a list of all registered resources with initialization.

type CouldNotDetermineEnabledRegionsError

type CouldNotDetermineEnabledRegionsError struct {
	Underlying error
}

func (CouldNotDetermineEnabledRegionsError) Error

type CouldNotSelectRegionError

type CouldNotSelectRegionError struct {
	Underlying error
}

func (CouldNotSelectRegionError) Error

func (err CouldNotSelectRegionError) Error() string

type InvalidResourceTypesSuppliedError

type InvalidResourceTypesSuppliedError struct {
	InvalidTypes []string
}

func (InvalidResourceTypesSuppliedError) Error

type InvalidTimeStringPassedError

type InvalidTimeStringPassedError struct {
	Entry      string
	Underlying error
}

func (InvalidTimeStringPassedError) Error

type Query

type Query struct {
	Regions              []string
	ExcludeRegions       []string
	ResourceTypes        []string
	ExcludeResourceTypes []string
	ExcludeAfter         *time.Time
	IncludeAfter         *time.Time
	ListUnaliasedKMSKeys bool
}

Query is a struct that represents the desired parameters for scanning resources within a given account

func NewQuery

func NewQuery(regions, excludeRegions, resourceTypes, excludeResourceTypes []string, excludeAfter, includeAfter *time.Time, listUnaliasedKMSKeys bool) (*Query, error)

NewQuery configures and returns a Query struct that can be passed into the InspectResources method

func (*Query) Validate

func (q *Query) Validate() error

Validate ensures the configured values for a Query are valid, returning an error if there are any invalid params, or nil if the Query is valid

type QueryCreationError

type QueryCreationError struct {
	Underlying error
}

func (QueryCreationError) Error

func (err QueryCreationError) Error() string

type ResourceInspectionError

type ResourceInspectionError struct {
	Underlying error
}

func (ResourceInspectionError) Error

func (err ResourceInspectionError) Error() string

type ResourceTypeAndExcludeFlagsBothPassedError

type ResourceTypeAndExcludeFlagsBothPassedError struct{}

func (ResourceTypeAndExcludeFlagsBothPassedError) Error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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