Documentation ¶
Index ¶
- Constants
- Variables
- func CleanAll(opts Options, region string) error
- func IsManagedS3Bucket(opts Options, region string, bucketName string) (bool, error)
- type Addresses
- type AutoScalingGroups
- type ClassicLoadBalancers
- type CloudFormationStacks
- type DHCPOptions
- type EKS
- type ElasticFileSystems
- type IAMInstanceProfiles
- type IAMOIDCProviders
- type IAMRoles
- type Instances
- type Interface
- type InternetGateways
- type KeyPairs
- type LaunchConfigurations
- type LaunchTemplates
- type LoadBalancers
- type NATGateway
- type NetworkInterfaces
- type Options
- type Route53ResourceRecordSets
- type RouteTables
- type S3Bucket
- type SQSQueues
- type SecurityGroups
- type Set
- type Snapshots
- type Subnets
- type TagMatcher
- type Tags
- type TargetGroups
- type Type
- type VPCEndpoints
- type VPCs
- type Volumes
Constants ¶
const (
NameTagKey = "Name"
)
Variables ¶
var GlobalTypeList = []Type{ IAMInstanceProfiles{}, IAMRoles{}, IAMOIDCProviders{}, Route53ResourceRecordSets{}, }
Non-regional AWS resource types, in dependency order
var RegionalTypeList = []Type{ CloudFormationStacks{}, EKS{}, ClassicLoadBalancers{}, LoadBalancers{}, AutoScalingGroups{}, LaunchConfigurations{}, LaunchTemplates{}, Instances{}, VPCEndpoints{}, NetworkInterfaces{}, Subnets{}, SecurityGroups{}, InternetGateways{}, RouteTables{}, NATGateway{}, VPCs{}, DHCPOptions{}, Snapshots{}, Volumes{}, Addresses{}, ElasticFileSystems{}, SQSQueues{}, TargetGroups{}, KeyPairs{}, S3Bucket{}, }
AWS resource types known to this script, in dependency order.
Functions ¶
Types ¶
type AutoScalingGroups ¶
type AutoScalingGroups struct{}
func (AutoScalingGroups) MarkAndSweep ¶
func (AutoScalingGroups) MarkAndSweep(opts Options, set *Set) error
type ClassicLoadBalancers ¶
type ClassicLoadBalancers struct{}
func (ClassicLoadBalancers) ListAll ¶
func (ClassicLoadBalancers) ListAll(opts Options) (*Set, error)
func (ClassicLoadBalancers) MarkAndSweep ¶
func (ClassicLoadBalancers) MarkAndSweep(opts Options, set *Set) error
type CloudFormationStacks ¶
type CloudFormationStacks struct{}
Cloud Formation Stacks
func (CloudFormationStacks) ListAll ¶
func (CloudFormationStacks) ListAll(opts Options) (*Set, error)
func (CloudFormationStacks) MarkAndSweep ¶
func (cfs CloudFormationStacks) MarkAndSweep(opts Options, set *Set) error
type DHCPOptions ¶
type DHCPOptions struct{}
DHCPOptions: https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#EC2.DescribeDhcpOptions
func (DHCPOptions) MarkAndSweep ¶
func (DHCPOptions) MarkAndSweep(opts Options, set *Set) error
type ElasticFileSystems ¶
type ElasticFileSystems struct{}
func (ElasticFileSystems) MarkAndSweep ¶
func (ElasticFileSystems) MarkAndSweep(opts Options, set *Set) error
type IAMInstanceProfiles ¶
type IAMInstanceProfiles struct{}
IAM Instance Profiles
func (IAMInstanceProfiles) MarkAndSweep ¶
func (IAMInstanceProfiles) MarkAndSweep(opts Options, set *Set) error
type IAMOIDCProviders ¶
type IAMOIDCProviders struct{}
func (IAMOIDCProviders) MarkAndSweep ¶
func (IAMOIDCProviders) MarkAndSweep(opts Options, set *Set) error
type Interface ¶
type Interface interface { // ARN returns the AWS ARN for the resource // (c.f. http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html). This // is only used for uniqueness in the Mark set, but ARNs are // intended to be globally unique across regions and accounts, so // that works. ARN() string // ResourceKey() returns a per-resource key, because ARNs might conflict if two objects // with the same name are created at different times (e.g. IAM roles) ResourceKey() string }
type InternetGateways ¶
type InternetGateways struct{}
func (InternetGateways) MarkAndSweep ¶
func (InternetGateways) MarkAndSweep(opts Options, set *Set) error
type LaunchConfigurations ¶
type LaunchConfigurations struct{}
LaunchConfigurations: http://docs.aws.amazon.com/sdk-for-go/api/service/autoscaling/#AutoScaling.DescribeLaunchConfigurations
func (LaunchConfigurations) ListAll ¶
func (LaunchConfigurations) ListAll(opts Options) (*Set, error)
func (LaunchConfigurations) MarkAndSweep ¶
func (LaunchConfigurations) MarkAndSweep(opts Options, set *Set) error
type LaunchTemplates ¶
type LaunchTemplates struct{}
LaunchTemplates https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#EC2.DescribeLaunchTemplates
func (LaunchTemplates) MarkAndSweep ¶
func (LaunchTemplates) MarkAndSweep(opts Options, set *Set) error
type LoadBalancers ¶
type LoadBalancers struct{}
func (LoadBalancers) MarkAndSweep ¶
func (LoadBalancers) MarkAndSweep(opts Options, set *Set) error
type NATGateway ¶
type NATGateway struct{}
NATGateway is a VPC component: https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html
func (NATGateway) ListAll ¶
func (NATGateway) ListAll(opts Options) (*Set, error)
ListAll populates a set will all available NATGateway resources.
func (NATGateway) MarkAndSweep ¶
func (NATGateway) MarkAndSweep(opts Options, set *Set) error
MarkAndSweep looks at the provided set, and removes resources older than its TTL that have been previously tagged.
type NetworkInterfaces ¶
type NetworkInterfaces struct{}
func (NetworkInterfaces) MarkAndSweep ¶
func (NetworkInterfaces) MarkAndSweep(opts Options, set *Set) error
type Options ¶
type Options struct { Session *session.Session `json:"-"` Account string Region string // Only resources which contain all IncludeTags will be considered for cleanup. IncludeTags TagMatcher // Any resources with at least one tag in ExcludeTags will be excluded from cleanup. // ExcludeTags takes precedence over IncludeTags - i.e. a resource that matches both // will be excluded. ExcludeTags TagMatcher // If set, any resources with a tag matching this key can override the global TTL (unless the global TTL is 0). // The value of the tag must be a valid Go time.Duration string. TTLTagKey string // Whether to actually delete resources, or just report what would be deleted. DryRun bool // If true, clean target groups. EnableTargetGroupClean bool // If true, clean key pairs. EnableKeyPairsClean bool // If true, clean VPC endpoints. EnableVPCEndpointsClean bool // If true, skip managed zone check and managed resource name check. SkipRoute53ManagementCheck bool // If true, clean DNS zones. EnableDNSZoneClean bool // If true, clean S3 Buckets. EnableS3BucketsClean bool // Resource record set types that shoud not be deleted. SkipResourceRecordSetTypes map[string]bool }
Options holds parameters for resource functions.
func (Options) ManagedPerTags ¶
ManagedPerTags returns whether the given list of tags is matched by all IncludeTags and no ExcludeTags.
type Route53ResourceRecordSets ¶
type Route53ResourceRecordSets struct{}
func (Route53ResourceRecordSets) ListAll ¶
func (Route53ResourceRecordSets) ListAll(opts Options) (*Set, error)
func (Route53ResourceRecordSets) MarkAndSweep ¶
func (rrs Route53ResourceRecordSets) MarkAndSweep(opts Options, set *Set) error
type RouteTables ¶
type RouteTables struct{}
func (RouteTables) MarkAndSweep ¶
func (RouteTables) MarkAndSweep(opts Options, set *Set) error
type SecurityGroups ¶
type SecurityGroups struct{}
SecurityGroups: https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#EC2.DescribeSecurityGroups
func (SecurityGroups) MarkAndSweep ¶
func (SecurityGroups) MarkAndSweep(opts Options, set *Set) error
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set keeps track of the first time we saw a particular ARN, and the global TTL. See Mark() for more details.
func (*Set) Mark ¶
Mark marks a particular resource as currently present, records when it was created or first seen, and advises on whether it should be deleted.
When determining whether a resource should be deleted, first the options for IncludeTags and ExcludeTags are applied against the provided tags. If the resource should be managed per tags, then the TTL is evaluated. Note that if the TTLTagKey option is set, the resource has a tag matching this key, and the global TTL is not set to 0, then the TTL duration in this tag's value will be used for this resource.
If Mark(r) returns true, the resource is managed per tags, and the TTL has expired for r and it should be deleted. If the created time is not provided, the current time is used instead.
func (*Set) MarkComplete ¶
MarkComplete figures out which ARNs were in previous passes but not this one, and eliminates them. It should only be run after all resources have been marked.
type Subnets ¶
type Subnets struct{}
Subnets: https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#EC2.DescribeSubnets
type TagMatcher ¶
TagMatcher maps keys to valid values. An empty set of values will result in matching tags with any value.
func TagMatcherForTags ¶
func TagMatcherForTags(tags []string) (TagMatcher, error)
TagMatcherForTags creates a new TagMatcher for the given list of tags provided in key=value format. If "=value" is not provided, then the TagMatcher will match any value for that key. (If the value is empty, only an empty tag value matches.)
func (TagMatcher) Matches ¶
func (tm TagMatcher) Matches(key, value string) bool
type TargetGroups ¶
type TargetGroups struct{}
func (TargetGroups) MarkAndSweep ¶
func (TargetGroups) MarkAndSweep(opts Options, set *Set) error
type Type ¶
type Type interface { // MarkAndSweep queries the resource in a specific region, using // the provided session (which has account-number acct), calling // res.Mark(<resource>) on each resource and deleting // appropriately. MarkAndSweep(opts Options, res *Set) error // ListAll queries all the resources this account has access to ListAll(opts Options) (*Set, error) }
type VPCEndpoints ¶
type VPCEndpoints struct{}
func (VPCEndpoints) MarkAndSweep ¶
func (VPCEndpoints) MarkAndSweep(opts Options, set *Set) error
Source Files ¶
- addresses.go
- asg.go
- clean.go
- cloud_formation_stacks.go
- dhcp_options.go
- efs.go
- eks.go
- elb.go
- elbv2.go
- iam_instance_profiles.go
- iam_oidc_providers.go
- iam_roles.go
- instance.go
- internet_gateways.go
- key_pairs.go
- launch_configs.go
- launch_templates.go
- list.go
- nat_gateway.go
- network_interface.go
- resource.go
- route53.go
- route_tables.go
- s3_bucket.go
- security_groups.go
- set.go
- snapshots.go
- sqs.go
- subnets.go
- tags.go
- target_groups.go
- volumes.go
- vpc_endpoints.go
- vpcs.go