config

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: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAwsResourceExclusionTagKey = "cloud-nuke-excluded"

Variables

This section is empty.

Functions

func ShouldInclude

func ShouldInclude(name string, includeREs []Expression, excludeREs []Expression) bool

ShouldInclude - Checks if a resource's Name should be included according to the inclusion and exclusion rules

Types

type Config

type Config struct {
	ACM                             ResourceType               `yaml:"ACM"`
	ACMPCA                          ResourceType               `yaml:"ACMPCA"`
	AMI                             ResourceType               `yaml:"AMI"`
	APIGateway                      ResourceType               `yaml:"APIGateway"`
	APIGatewayV2                    ResourceType               `yaml:"APIGatewayV2"`
	AccessAnalyzer                  ResourceType               `yaml:"AccessAnalyzer"`
	AutoScalingGroup                ResourceType               `yaml:"AutoScalingGroup"`
	BackupVault                     ResourceType               `yaml:"BackupVault"`
	CloudWatchAlarm                 ResourceType               `yaml:"CloudWatchAlarm"`
	CloudWatchDashboard             ResourceType               `yaml:"CloudWatchDashboard"`
	CloudWatchLogGroup              ResourceType               `yaml:"CloudWatchLogGroup"`
	CloudtrailTrail                 ResourceType               `yaml:"CloudtrailTrail"`
	CodeDeployApplications          ResourceType               `yaml:"CodeDeployApplications"`
	ConfigServiceRecorder           ResourceType               `yaml:"ConfigServiceRecorder"`
	ConfigServiceRule               ResourceType               `yaml:"ConfigServiceRule"`
	DBClusters                      ResourceType               `yaml:"DBClusters"`
	DBInstances                     ResourceType               `yaml:"DBInstances"`
	DBSubnetGroups                  ResourceType               `yaml:"DBSubnetGroups"`
	DynamoDB                        ResourceType               `yaml:"DynamoDB"`
	EBSVolume                       ResourceType               `yaml:"EBSVolume"`
	EC2                             ResourceType               `yaml:"EC2"`
	EC2DedicatedHosts               ResourceType               `yaml:"EC2DedicatedHosts"`
	EC2DHCPOption                   ResourceType               `yaml:"EC2DhcpOption"`
	EC2KeyPairs                     ResourceType               `yaml:"EC2KeyPairs"`
	ECRRepository                   ResourceType               `yaml:"ECRRepository"`
	ECSCluster                      ResourceType               `yaml:"ECSCluster"`
	ECSService                      ResourceType               `yaml:"ECSService"`
	EKSCluster                      ResourceType               `yaml:"EKSCluster"`
	ELBv1                           ResourceType               `yaml:"ELBv1"`
	ELBv2                           ResourceType               `yaml:"ELBv2"`
	ElasticFileSystem               ResourceType               `yaml:"ElasticFileSystem"`
	ElasticIP                       ResourceType               `yaml:"ElasticIP"`
	Elasticache                     ResourceType               `yaml:"Elasticache"`
	ElasticacheParameterGroups      ResourceType               `yaml:"ElasticacheParameterGroups"`
	ElasticacheSubnetGroups         ResourceType               `yaml:"ElasticacheSubnetGroups"`
	GuardDuty                       ResourceType               `yaml:"GuardDuty"`
	IAMGroups                       ResourceType               `yaml:"IAMGroups"`
	IAMPolicies                     ResourceType               `yaml:"IAMPolicies"`
	IAMRoles                        ResourceType               `yaml:"IAMRoles"`
	IAMServiceLinkedRoles           ResourceType               `yaml:"IAMServiceLinkedRoles"`
	IAMUsers                        ResourceType               `yaml:"IAMUsers"`
	KMSCustomerKeys                 KMSCustomerKeyResourceType `yaml:"KMSCustomerKeys"`
	KinesisStream                   ResourceType               `yaml:"KinesisStream"`
	LambdaFunction                  ResourceType               `yaml:"LambdaFunction"`
	LambdaLayer                     ResourceType               `yaml:"LambdaLayer"`
	LaunchConfiguration             ResourceType               `yaml:"LaunchConfiguration"`
	LaunchTemplate                  ResourceType               `yaml:"LaunchTemplate"`
	MacieMember                     ResourceType               `yaml:"MacieMember"`
	MSKCluster                      ResourceType               `yaml:"MSKCluster"`
	NatGateway                      ResourceType               `yaml:"NatGateway"`
	OIDCProvider                    ResourceType               `yaml:"OIDCProvider"`
	OpenSearchDomain                ResourceType               `yaml:"OpenSearchDomain"`
	Redshift                        ResourceType               `yaml:"Redshift"`
	RdsSnapshot                     ResourceType               `yaml:"RdsSnapshot"`
	S3                              ResourceType               `yaml:"s3"`
	SNS                             ResourceType               `yaml:"SNS"`
	SQS                             ResourceType               `yaml:"SQS"`
	SageMakerNotebook               ResourceType               `yaml:"SageMakerNotebook"`
	SecretsManagerSecrets           ResourceType               `yaml:"SecretsManager"`
	SecurityHub                     ResourceType               `yaml:"SecurityHub"`
	Snapshots                       ResourceType               `yaml:"Snapshots"`
	TransitGateway                  ResourceType               `yaml:"TransitGateway"`
	TransitGatewayRouteTable        ResourceType               `yaml:"TransitGatewayRouteTable"`
	TransitGatewaysVpcAttachment    ResourceType               `yaml:"TransitGatewaysVpcAttachment"`
	TransitGatewayPeeringAttachment ResourceType               `yaml:"TransitGatewayPeeringAttachment"`
	VPC                             ResourceType               `yaml:"VPC"`
}

Config - the config object we pass around

func GetConfig

func GetConfig(filePath string) (*Config, error)

GetConfig - Unmarshall the config file and parse it into a config object.

func (*Config) AddExcludeAfterTime

func (c *Config) AddExcludeAfterTime(excludeAfter *time.Time)

func (*Config) AddIncludeAfterTime

func (c *Config) AddIncludeAfterTime(includeAfter *time.Time)

type Expression

type Expression struct {
	RE regexp.Regexp
}

func (*Expression) UnmarshalText

func (expression *Expression) UnmarshalText(data []byte) error

UnmarshalText - Internally used by yaml.Unmarshal to unmarshall an Expression field

type FilterRule

type FilterRule struct {
	NamesRegExp []Expression `yaml:"names_regex"`
	TimeAfter   *time.Time   `yaml:"time_after"`
	TimeBefore  *time.Time   `yaml:"time_before"`
	Tag         *string      `yaml:"tag"` // A tag to filter resources by. (e.g., If set under ExcludedRule, resources with this tag will be excluded).
}

type KMSCustomerKeyResourceType

type KMSCustomerKeyResourceType struct {
	IncludeUnaliasedKeys bool `yaml:"include_unaliased_keys"`
	ResourceType         `yaml:",inline"`
}

type ResourceType

type ResourceType struct {
	IncludeRule FilterRule `yaml:"include"`
	ExcludeRule FilterRule `yaml:"exclude"`
}

func (ResourceType) ShouldInclude

func (r ResourceType) ShouldInclude(value ResourceValue) bool

func (ResourceType) ShouldIncludeBasedOnTag

func (r ResourceType) ShouldIncludeBasedOnTag(tags map[string]string) bool

func (ResourceType) ShouldIncludeBasedOnTime

func (r ResourceType) ShouldIncludeBasedOnTime(time time.Time) bool

type ResourceValue

type ResourceValue struct {
	Name *string
	Time *time.Time
	Tags map[string]string
}

Jump to

Keyboard shortcuts

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