provider

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package provider provides the core interfaces of Terracognita by defining the Provider and Resource and also the main function named Impoort

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Import

func Import(ctx context.Context, p Provider, hcl, tfstate writer.Writer, f *filter.Filter, out io.Writer) error

Import imports from the Provider p all the resources filtered by f and writes the result to the hcl or tfstate if those are not nil

Types

type Provider

type Provider interface {
	// Region returns the actual region in which the
	// provider is based
	Region() string

	// ResourceTypes returns all the resource types from
	// the Provider
	ResourceTypes() []string

	// HasResourceType validates if the string t is a valid
	// resource type for this provider
	HasResourceType(t string) bool

	// Resources returns all the Resources of the resourceType
	// on the cloud provider
	Resources(ctx context.Context, resourceType string, f *filter.Filter) ([]Resource, error)

	// TFClient returns the Terraform client which may change
	// on the provider
	TFClient() interface{}

	// TFProvider returns the Terraform provider
	TFProvider() *schema.Provider

	// String returns the string representation of the Provider
	// which is the shorted version (Amazon Web Services = aws)
	String() string

	// TagKey returns the different name used to identify
	// tags on the cloud provider
	TagKey() string
}

Provider is the ggeneral interface used to abstract a cloud provider from Terraform

type Resource

type Resource interface {
	// ID is the ID of the Resource
	ID() string

	// Type is the type of resource (ex: aws_instance)
	Type() string

	// InstanceState is the Terraform state of the resource
	// it contains important elements like `Attributes`
	InstanceState() *terraform.InstanceState

	// Name is the resource name given by Terracognita
	Name() string

	// TFResource is the definition of that resource
	TFResource() *schema.Resource

	// Data is the actual data of the Resource
	Data() *schema.ResourceData

	// Provider is the Provider of that Resource
	Provider() Provider

	// ImportResourceState imports the Resource state
	// to the Resource and could return []Resource if
	// it imported more than one state, this list does not
	// include the actual Resource on parameters, so if
	// len([]Resource) == 0 means only the Resource is imported
	ImportState() ([]Resource, error)

	// Read read the remote information of the Resource to the
	// state and calculates the ResourceInstanceObject
	Read(f *filter.Filter) error

	// State calculates the state of the Resource and
	// writes it to w
	State(w writer.Writer) error

	// HCL returns the HCL configuration of the Resource and
	// writes it to HCL
	HCL(w writer.Writer) error

	// InstanceInfo returns the InstanceInfo of this Resource
	InstanceInfo() *terraform.InstanceInfo

	// CoreConfigSchema returns the configschema.Block of the
	// Resource
	CoreConfigSchema() *configschema.Block

	// ResourceInstanceObject is the calculated states.ResourceInstanceObject
	// after 'Read' has been called
	ResourceInstanceObject() *states.ResourceInstanceObject

	// AttributesReference return the list of possible value
	// to be interpolated with the resource
	AttributesReference() ([]string, error)
}

Resource represents the minimal information needed to define a Provider resource

func NewResource

func NewResource(id, rt string, p Provider) Resource

NewResource returns an implementation of the Resource

Jump to

Keyboard shortcuts

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