resource

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2018 License: MPL-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppFs = afero.NewOsFs()

AppFs is an abstraction of the file system to allow mocking in tests.

Functions

This section is empty.

Types

type APIDesc

type APIDesc struct {
	TerraformType      string
	DescribeOutputName []string
	DeleteID           string
	Describe           interface{}
	DescribeInput      interface{}
	Select             func(Resources, interface{}, Filter, *AWSClient) []Resources
}

APIDesc stores the necessary information about a single resource type (identified by its terraform type) to list and delete resources of that type via the go-aws-sdk and Terraform AWS provider API.

func Supported

func Supported(c *AWSClient) []APIDesc

Supported returns for all supported resource types the API information to list (go-sdk API) and delete (AWS Terraform provider API) corresponding resources.

type AWSClient

type AWSClient struct {
	EC2conn ec2iface.EC2API
	ASconn  autoscalingiface.AutoScalingAPI
	ELBconn elbiface.ELBAPI
	R53conn route53iface.Route53API
	CFconn  cloudformationiface.CloudFormationAPI
	EFSconn efsiface.EFSAPI
	IAMconn iamiface.IAMAPI
	KMSconn kmsiface.KMSAPI
	S3conn  s3iface.S3API
	STSconn stsiface.STSAPI
}

AWSClient stores all the clients of AWS services including their sessions.

type Filter

type Filter interface {
	Validate(as []APIDesc) error
	Matches(resType string, id string, tags ...map[string]string) bool
	Types() []string
}

Filter selects resources for deletion.

type Resource

type Resource struct {
	Type  string // we use the terraform type to identify the resource type
	ID    string
	Attrs map[string]string
	Tags  map[string]string
}

Resource contains information about a single AWS resource.

type Resources

type Resources []*Resource

Resources is a list of AWS resources.

func List

func List(a APIDesc) (Resources, interface{})

List lists all AWS resources based on a given API description.

type YamlCfg

type YamlCfg map[string]yamlEntry

YamlCfg represents the data structure of a yaml file that is used as a contract to select resources. Each yamlEntry selects the resources of a particular resource type.

type YamlFilter

type YamlFilter struct {
	// contains filtered or unexported fields
}

YamlFilter selects resources stated in a yaml configuration for deletion.

func NewFilter

func NewFilter(yamlFile string) *YamlFilter

NewFilter creates a new filter to select resources for deletion based on the path of yaml file.

func (YamlFilter) Matches

func (f YamlFilter) Matches(resType string, id string, tags ...map[string]string) bool

Matches checks whether a resource (given by its type and tags) matches the configured filter criteria for tags and ids.

func (YamlFilter) Types

func (f YamlFilter) Types() []string

Types returns all the resource types stated in the yaml config. We use the same identifiers of resource types as the Terraform AWS provider.

func (YamlFilter) Validate

func (f YamlFilter) Validate(as []APIDesc) error

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

Jump to

Keyboard shortcuts

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