aws

package
v0.37.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: MIT Imports: 23 Imported by: 3

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 added in v0.1.8

func GetEnabledRegions() ([]string, error)

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

func GetTargetRegions added in v0.1.11

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 added in v0.11.7

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 added in v0.1.9

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

IsNukeable - Checks if we should nuke a resource or not

func IsValidResourceType added in v0.1.9

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

IsValidResourceType - Checks if a resourceType is valid or not

func ListResourceTypes added in v0.1.9

func ListResourceTypes() []string

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

func NewSession added in v0.33.0

func NewSession(region string) *session.Session

func NukeAllResources

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

NukeAllResources - Nukes all aws resources

func Session2cfg added in v0.37.2

func Session2cfg(ctx context.Context, session *session.Session) (awsgoV2.Config, error)

Types

type AwsAccountResources

type AwsAccountResources struct {
	Resources map[string]AwsResources
}

AwsAccountResources is a struct that represents the resources found in a single AWS account

func GetAllResources

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

GetAllResources - Lists all aws resources

func (*AwsAccountResources) GetRegion added in v0.11.7

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

func (*AwsAccountResources) TotalResourceCount added in v0.22.0

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 AwsResource added in v0.34.0

type AwsResource interface {
	Init(session *session.Session)
	InitV2(cfg awsgoV2.Config)
	ResourceName() string
	ResourceIdentifiers() []string
	MaxBatchSize() int
	Nuke(identifiers []string) error
	GetAndSetIdentifiers(c context.Context, configObj config.Config) ([]string, error)
	IsNukable(string) (bool, error)
	IsUsingV2() bool

	PrepareContext(context.Context, config.ResourceType) error
	GetAndSetResourceConfig(config.Config) config.ResourceType
}

AwsResource is an interface that represents a single AWS resource

func GetAllRegisteredResources added in v0.33.0

func GetAllRegisteredResources() []*AwsResource

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

func GetAndInitRegisteredResources added in v0.33.0

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

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

type AwsResources

type AwsResources struct {
	Resources []*AwsResource
}

AwsResources is a struct to hold multiple instances of AwsResource.

func (*AwsResources) CountOfResourceType added in v0.34.0

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

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

func (*AwsResources) IdentifiersForResourceType added in v0.34.0

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

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

func (*AwsResources) MapResourceTypeToIdentifiers added in v0.34.0

func (arr *AwsResources) MapResourceTypeToIdentifiers() map[string][]string

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

func (*AwsResources) ResourceTypePresent added in v0.34.0

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

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

type CouldNotDetermineEnabledRegionsError added in v0.11.7

type CouldNotDetermineEnabledRegionsError struct {
	Underlying error
}

func (CouldNotDetermineEnabledRegionsError) Error added in v0.11.7

type CouldNotSelectRegionError added in v0.11.7

type CouldNotSelectRegionError struct {
	Underlying error
}

func (CouldNotSelectRegionError) Error added in v0.11.7

func (err CouldNotSelectRegionError) Error() string

type InvalidResourceTypesSuppliedError added in v0.11.7

type InvalidResourceTypesSuppliedError struct {
	InvalidTypes []string
}

func (InvalidResourceTypesSuppliedError) Error added in v0.11.7

type InvalidTimeStringPassedError added in v0.11.7

type InvalidTimeStringPassedError struct {
	Entry      string
	Underlying error
}

func (InvalidTimeStringPassedError) Error added in v0.11.7

type Query added in v0.11.7

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

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

func NewQuery added in v0.11.7

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

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

func (*Query) Validate added in v0.11.7

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 added in v0.11.7

type QueryCreationError struct {
	Underlying error
}

func (QueryCreationError) Error added in v0.11.7

func (err QueryCreationError) Error() string

type ResourceInspectionError added in v0.11.7

type ResourceInspectionError struct {
	Underlying error
}

func (ResourceInspectionError) Error added in v0.11.7

func (err ResourceInspectionError) Error() string

type ResourceTypeAndExcludeFlagsBothPassedError added in v0.11.7

type ResourceTypeAndExcludeFlagsBothPassedError struct{}

func (ResourceTypeAndExcludeFlagsBothPassedError) Error added in v0.11.7

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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