tfimport

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package tfimport provides utilities to import resources from a Terraform config.

Index

Constants

This section is empty.

Variables

View Source
var Importers = map[string]resourceImporter{}/* 102 elements not displayed */

Importers defines all supported resource importers. These can be sorted in Vim using ":SortRangesByHeader" from https://github.com/jrhouston/tfk8s

View Source
var RequiresInteractive = map[string]bool{
	"google_billing_budget":        true,
	"google_resource_manager_lien": true,
}

RequiresInteractive lists resources which require interactivity and can't be fully automatically imported.

View Source
var Unimportable = map[string]bool{
	"google_bigquery_dataset_access": true,
	"google_service_account_key":     true,
	"google_storage_bucket_object":   true,
	"local_file":                     true,
	"null_resource":                  true,
	"random_password":                true,
	"random_pet":                     true,
	"random_shuffle":                 true,
	"random_string":                  true,
	"tls_private_key":                true,
}

Unimportable defines resources that are explicitly not supported by their provider.

Functions

func DoesNotExist

func DoesNotExist(output string) bool

DoesNotExist parses the output of a `terraform import` command to determine if it indicated that a resource does not exist.

func Import

func Import(rn runner.Runner, ir *Resource, inputDir string, terraformPath string, interactive bool) (output string, err error)

Import runs `terraform import` for the given importable resource. It parses the output string to determine to determine if the provider said the resource doesn't exist or isn't importable.

func NotImportable

func NotImportable(output string) bool

NotImportable parses the output of a `terraform import` command to determine if it indicated that a resource is not importable.

func Run

func Run(rn runner.Runner, importRn runner.Runner, runArgs *RunArgs) error

Run executes the main tfimport logic.

Types

type Resource

type Resource struct {
	Change         terraform.ResourceChange
	ProviderConfig importer.ConfigMap
	Importer       resourceImporter
}

Resource represents a resource and an importer that can import it.

func Importable

func Importable(rc terraform.ResourceChange, pcv importer.ConfigMap, interactive bool) (*Resource, bool)

Importable returns an importable Resource which contains an Importer, and whether it successfully created that resource. pcv represents provider config values, which will be used if the resource does not have values defined.

func (Resource) ImportID

func (ir Resource) ImportID(interactive bool) (string, error)

ImportID is a convenience function for passing a resource's information to its importer.

type RunArgs

type RunArgs struct {
	InputDir      string
	TerraformPath string
	DryRun        bool
	Interactive   bool
	Verbose       bool

	// This is a "set" of resource types to import.
	// If not nil and not empty, will import only resources which match it.
	SpecificResourceTypes map[string]bool
}

RunArgs are the supported tfimport run arguments.

Directories

Path Synopsis
Package importer defines resource-specific implementations for interface Importer.
Package importer defines resource-specific implementations for interface Importer.

Jump to

Keyboard shortcuts

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