Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPlan ¶
GetPlan obtains a Terraform plan from the module in the given working directory. It does so by running a series of Terraform commands.
func GetVersion ¶
GetVersion obtains the version of the configured Terraform binary.
func WriteMoveCommands ¶
WriteMoveCommands encodes the given moves as a series of Terraform CLI commands and writes them to the given writer.
Moving resources across working directories requires a bit of extra work. In those cases, WriteMoveCommands will write a series of commands that copies the state of the working directories involved to the local filesystem, performs the moves, and pushes the states back to configured backends.
Since Terraform's state can contain sensitive information, the copies are written in the same directory as the working directories. This allows the user to know exactly where their state is stored. The files are not deleted automatically, in case the user wants to use them (to revert any changes, for instance).
func WriteMovedBlocks ¶
WriteMovedBlocks encodes the given moves as a series of Terraform moved blocks, in HCL, and writes them to the given writer.
Currently, moved blocks cannot be used to move resources between different working directories. If the given moves contain such a move, WriteMovedBlocks returns an error.
Types ¶
type Move ¶
type Move struct { // The working directory the resource is being moved from. Equal to // ToWorkdir when the resource is being moved within the same working // directory. FromWorkdir string // The working directory the resource is being moved to. Equal to // FromWorkdir when the resource is being moved within the same working // directory. ToWorkdir string // The resource's address before the move. FromAddress string // The resource's address after the move. ToAddress string }
A Move represents a an object in Terraform's state that should be moved to another address and possibly to another working directory. This is analogous to a moved block or a state mv command.
type Option ¶
type Option func(*settings)
An Option configures how Terraform commands are run.
func WithSkipInit ¶
WithSkipInit configures whether the init step should be skipped. By default, this step is not skipped.
Skipping the init step can save time, but subsequent steps may fail if the module was not initialized beforehand.
func WithSkipRefresh ¶
WithSkipRefresh configures whether the refresh step should be skipped. By default, this step is not skipped.
Skipping the refresh step can save time, but can result in Terraform basing its plan on stale data.
func WithTerraformBin ¶
WithTerraformBin replaces the Terraform binary with the provided executable. If this option is not provided, it defaults to the `terraform` executable in the current PATH.
func WithWorkdir ¶
WithWorkdir sets the directory Terraform commands will run. If this option is not provided, it defaults to the current working directory.