resource

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2022 License: MPL-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DependencyOrder is the order in which resource types should be deleted,
	// since dependent resources need to be deleted before their dependencies
	// (e.g. aws_subnet before aws_vpc)
	DependencyOrder = map[string]int{
		"aws_lambda_function":      10100,
		"aws_ecs_cluster":          10000,
		"aws_autoscaling_group":    9990,
		"aws_instance":             9980,
		"aws_key_pair":             9970,
		"aws_elb":                  9960,
		"aws_vpc_endpoint":         9950,
		"aws_nat_gateway":          9940,
		"aws_cloudformation_stack": 9930,
		"aws_route53_zone":         9920,
		"aws_efs_file_system":      9910,
		"aws_launch_configuration": 9900,
		"aws_eip":                  9890,
		"aws_internet_gateway":     9880,
		"aws_subnet":               9870,
		"aws_route_table":          9860,
		"aws_security_group":       9850,
		"aws_network_acl":          9840,
		"aws_vpc":                  9830,
		"aws_db_instance":          9825,
		"aws_iam_policy":           9820,
		"aws_iam_group":            9810,
		"aws_iam_user":             9800,
		"aws_iam_role":             9790,
		"aws_iam_instance_profile": 9780,
		"aws_s3_bucket":            9750,
		"aws_ami":                  9740,
		"aws_ebs_volume":           9730,
		"aws_ebs_snapshot":         9720,
		"aws_kms_alias":            9610,
		"aws_kms_key":              9600,
		"aws_network_interface":    9000,
		"aws_cloudwatch_log_group": 8900,
		"aws_cloudtrail":           8800,
	}
)

Functions

func GetTags

func GetTags(r *terraform.Resource) (map[string]string, error)

func List

func List(ctx context.Context, filter *Filter, clients map[aws.ClientKey]aws.Client,
	providers map[aws.ClientKey]provider.TerraformProvider, outputType string) []terradozerRes.DestroyableResource

Types

type Created

type Created struct {
	Before *CreatedTime `yaml:",omitempty"`
	After  *CreatedTime `yaml:",omitempty"`
}

type CreatedTime

type CreatedTime struct {
	time.Time `yaml:",omitempty"`
}

func (*CreatedTime) UnmarshalYAML

func (c *CreatedTime) UnmarshalYAML(unmarshal func(interface{}) error) error

type Filter

type Filter map[string][]TypeFilter

Filter represents the content of a yaml file that is used to filter resources for deletion.

func NewFilter

func NewFilter(path string) (*Filter, error)

NewFilter creates a resource filter defined via a given path to a yaml file.

func (Filter) Apply

func (f Filter) Apply(res []terraform.Resource) []terraform.Resource

Apply applies the filter to the given resources.

func (Filter) Match

func (f Filter) Match(r terraform.Resource) bool

Match checks whether a resource matches the filter criteria.

func (Filter) Types

func (f Filter) Types() []string

Types returns all the resource types in the config in their dependency order.

func (Filter) Validate

func (f Filter) Validate() error

Validate checks if all resource types appearing in the config are currently supported.

type StringFilter

type StringFilter struct {
	Pattern string `yaml:",omitempty"`
	Negate  bool
}

func (*StringFilter) UnmarshalYAML

func (f *StringFilter) UnmarshalYAML(unmarshal func(interface{}) error) error

type StringMatcher

type StringMatcher interface {
	// contains filtered or unexported methods
}

type TypeFilter

type TypeFilter struct {
	ID      *StringFilter           `yaml:",omitempty"`
	Tagged  *bool                   `yaml:",omitempty"`
	Tags    map[string]StringFilter `yaml:",omitempty"`
	Created *Created                `yaml:",omitempty"`
}

TypeFilter represents an entry in the yaml file to filter the resources of a particular resource type.

func (TypeFilter) MatchTagged

func (f TypeFilter) MatchTagged(tags map[string]string) bool

MatchTagged filters resources with a non-empty or empty tag set.

func (TypeFilter) MatchTags

func (f TypeFilter) MatchTags(tags map[string]string) bool

MatchTags checks whether a resource's tag set matches the filter.

Jump to

Keyboard shortcuts

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