tfmod

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

tfmod

tfmod outputs the dependencies and dependents for Terraform.

Description

tfmod helps you understand the relationships between your Terraform state directories and modules. It shows which state directories use which modules and vice versa.

  • dependency: Finds the modules used by the specified state directories.
  • dependent: Finds the state directories that use the specified modules.

A "state directory" is where you run terraform plan or terraform apply. It typically stores the terraform.tfstate file.

For example, if you modify a Terraform module, you can see which state directories are affected.

$ tfmod dependent --module=module/foo
state/prd state/stg

With tfmod, you can easily identify relationships and dependencies in your Terraform configurations, making it easier to manage changes and understand their impacts.

Installation

Download binary

Download the latest compiled binaries and put it anywhere in your executable path.

Pull container image

You can pull container image from GitHub Packages.

docker pull ghcr.io/tmknom/tfmod

Usage

Assume you have the following directory structure for managing Terraform:

├── state
│   ├── prd
│   └── stg
└── module
    ├── bar
    └── foo

You can run the subcommands as follows:

Download Terraform modules

Download all the Terraform modules for the state directories under the current directory.

tfmod download

You can also specify the base directory for the state directories.

tfmod download --base state

[!TIP]

To analyze dependencies with tfmod, you need to download Terraform modules first. If you have already run terraform get or terraform init, this command is not needed.

Explore dependencies

Specify a state directory to find the Terraform modules it depends on.

tfmod dependency --state=state/prd

You can specify multiple state directories separated by commas.

tfmod dependency --state=state/prd,state/stg
Explore dependents

Specify a Terraform module to find the state directories that reference it.

tfmod dependent --module=module/foo

You can specify multiple Terraform modules separated by commas.

tfmod dependent --module=module/foo,module/bar

N/A

Release notes

See GitHub Releases.

License

Apache 2 Licensed. See LICENSE for full details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	*IO
	*Ldflags

	*GlobalFlags
	// contains filtered or unexported fields
}

func NewApp

func NewApp(io *IO, ldflags *Ldflags) *App

func (*App) Run

func (a *App) Run(ctx context.Context, args []string) error

type DependencyFlags added in v0.0.6

type DependencyFlags struct {
	StatePaths []string
	*GlobalFlags
}

func NewDependencyFlags added in v0.0.6

func NewDependencyFlags(globalFlags *GlobalFlags) *DependencyFlags

func (*DependencyFlags) GoString added in v0.0.6

func (f *DependencyFlags) GoString() string

type DependencyRunner added in v0.0.6

type DependencyRunner struct {
	terraform.Store
	*IO
	// contains filtered or unexported fields
}

func NewDependencyRunner added in v0.0.6

func NewDependencyRunner(flags *DependencyFlags, store terraform.Store, io *IO) *DependencyRunner

func (*DependencyRunner) List added in v0.0.6

func (r *DependencyRunner) List() ([]string, error)

func (*DependencyRunner) Run added in v0.0.6

func (r *DependencyRunner) Run() error

type DependentFlags added in v0.0.6

type DependentFlags struct {
	ModulePaths []string
	*GlobalFlags
}

func NewDependentFlags added in v0.0.6

func NewDependentFlags(globalFlags *GlobalFlags) *DependentFlags

func (*DependentFlags) GoString added in v0.0.6

func (f *DependentFlags) GoString() string

type DependentRunner added in v0.0.6

type DependentRunner struct {
	terraform.Store
	*IO
	// contains filtered or unexported fields
}

func NewDependentRunner added in v0.0.6

func NewDependentRunner(flags *DependentFlags, store terraform.Store, io *IO) *DependentRunner

func (*DependentRunner) List added in v0.0.6

func (r *DependentRunner) List() ([]string, error)

func (*DependentRunner) Run added in v0.0.6

func (r *DependentRunner) Run() error

type DownloadFlags added in v0.0.6

type DownloadFlags struct {
	MaxConcurrent int
	*GlobalFlags
}

func NewDownloadFlags added in v0.0.6

func NewDownloadFlags(globalFlags *GlobalFlags) *DownloadFlags

func (*DownloadFlags) GoString added in v0.0.6

func (f *DownloadFlags) GoString() string

type DownloadRunner added in v0.0.6

type DownloadRunner struct {
	*IO
	// contains filtered or unexported fields
}

func NewDownloadRunner added in v0.0.6

func NewDownloadRunner(flags *DownloadFlags, io *IO) *DownloadRunner

func (*DownloadRunner) Run added in v0.0.6

func (r *DownloadRunner) Run(ctx context.Context) error

func (*DownloadRunner) TerraformGet added in v0.0.6

func (r *DownloadRunner) TerraformGet(ctx context.Context) ([]string, error)

type GlobalFlags added in v0.0.2

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

func (*GlobalFlags) BaseDir added in v0.0.2

func (f *GlobalFlags) BaseDir() *dir.BaseDir

func (*GlobalFlags) Format added in v0.0.4

func (f *GlobalFlags) Format() string

func (*GlobalFlags) GoString added in v0.0.3

func (f *GlobalFlags) GoString() string

type IO

type IO struct {
	InReader  io.Reader
	OutWriter io.Writer
	ErrWriter io.Writer
}

func (*IO) IsPipe added in v0.2.0

func (i *IO) IsPipe() bool

func (*IO) Read added in v0.2.0

func (i *IO) Read() []string

type Ldflags

type Ldflags struct {
	Name    string
	Version string
	Commit  string
	Date    string
	Url     string
}

Directories

Path Synopsis
cmd
tfmod command
internal
dir

Jump to

Keyboard shortcuts

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