2014-05-24 21:27:58 +02:00
package command
import (
2014-06-19 01:42:13 +02:00
"fmt"
2014-05-24 21:27:58 +02:00
"strings"
2017-01-19 05:50:45 +01:00
"github.com/hashicorp/terraform/backend"
cli: Add initial command views abstraction
Terraform supports multiple output formats for several sub-commands.
The default format is user-readable text, but many sub-commands support
a `-json` flag to output a machine-readable format for the result. The
output command also supports a `-raw` flag for a simpler, scripting-
focused machine readable format.
This commit adds a "views" abstraction, intended to help ensure
consistency between the various output formats. This extracts the render
specific code from the command package, and moves it into a views
package. Each command is expected to create an interface for its view,
and one or more implementations of that interface.
By doing so, we separate the concerns of generating the sub-command
result from rendering the result in the specified output format. This
should make it easier to ensure that all output formats will be updated
together when changes occur in the result-generating phase.
There are some other consequences of this restructuring:
- Views now directly access the terminal streams, rather than the
now-redundant cli.Ui instance;
- With the reorganization of commands, parsing CLI arguments is now the
responsibility of a separate "arguments" package.
For now, views are added only for the output sub-command, as an example.
Because this command uses code which is shared with the apply and
refresh commands, those are also partially updated.
2021-01-27 21:51:40 +01:00
"github.com/hashicorp/terraform/command/arguments"
"github.com/hashicorp/terraform/command/views"
2021-02-02 16:35:45 +01:00
"github.com/hashicorp/terraform/plans/planfile"
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 19:33:53 +02:00
"github.com/hashicorp/terraform/tfdiags"
2014-05-24 21:27:58 +02:00
)
// ApplyCommand is a Command implementation that applies a Terraform
// configuration and actually builds or changes infrastructure.
type ApplyCommand struct {
2014-07-13 05:21:46 +02:00
Meta
2014-10-01 06:49:24 +02:00
// If true, then this apply command will become the "destroy"
// command. It is just like apply but only processes a destroy.
Destroy bool
2014-05-24 21:27:58 +02:00
}
2021-02-18 23:23:34 +01:00
func ( c * ApplyCommand ) Run ( rawArgs [ ] string ) int {
// Parse and apply global view arguments
common , rawArgs := arguments . ParseView ( rawArgs )
c . View . Configure ( common )
// Parse and validate flags
args , diags := arguments . ParseApply ( rawArgs )
// Instantiate the view, even if there are flag errors, so that we render
// diagnostics according to the desired view
var view views . Apply
view = views . NewApply ( args . ViewType , c . Destroy , c . RunningInAutomation , c . View )
if diags . HasErrors ( ) {
view . Diagnostics ( diags )
view . HelpPrompt ( )
return 1
2014-10-01 06:49:24 +02:00
}
2021-02-18 23:23:34 +01:00
// Check for user-supplied plugin path
var err error
if c . pluginPath , err = c . loadPluginPath ( ) ; err != nil {
diags = diags . Append ( err )
view . Diagnostics ( diags )
2014-06-19 01:42:13 +02:00
return 1
}
2021-02-18 23:23:34 +01:00
// Attempt to load the plan file, if specified
planFile , diags := c . LoadPlanFile ( args . PlanPath )
2021-02-08 19:29:42 +01:00
if diags . HasErrors ( ) {
2021-02-18 23:23:34 +01:00
view . Diagnostics ( diags )
return 1
}
// Check for invalid combination of plan file and variable overrides
if planFile != nil && ! args . Vars . Empty ( ) {
diags = diags . Append ( tfdiags . Sourceless (
tfdiags . Error ,
"Can't set variables when applying a saved plan" ,
"The -var and -var-file options cannot be used when applying a saved plan file, because a saved plan includes the variable values that were set when it was created." ,
) )
view . Diagnostics ( diags )
2021-02-08 19:29:42 +01:00
return 1
}
2018-10-16 16:47:32 +02:00
2021-02-18 23:23:34 +01:00
// FIXME: the -input flag value is needed to initialize the backend and the
// operation, but there is no clear path to pass this value down, so we
// continue to mutate the Meta object state for now.
c . Meta . input = args . InputEnabled
// FIXME: the -parallelism flag is used to control the concurrency of
// Terraform operations. At the moment, this value is used both to
// initialize the backend via the ContextOpts field inside CLIOpts, and to
// set a largely unused field on the Operation request. Again, there is no
// clear path to pass this value down, so we continue to mutate the Meta
// object state for now.
c . Meta . parallelism = args . Operation . Parallelism
// Prepare the backend, passing the plan file if present, and the
// backend-specific arguments
be , beDiags := c . PrepareBackend ( planFile , args . State )
diags = diags . Append ( beDiags )
if diags . HasErrors ( ) {
view . Diagnostics ( diags )
return 1
2021-02-02 16:35:45 +01:00
}
2021-02-18 23:23:34 +01:00
// Build the operation request
opReq , opDiags := c . OperationRequest ( be , view , planFile , args . Operation )
diags = diags . Append ( opDiags )
// Collect variable value and add them to the operation request
diags = diags . Append ( c . GatherVariables ( opReq , args . Vars ) )
// Before we delegate to the backend, we'll print any warning diagnostics
// we've accumulated here, since the backend will start fresh with its own
// diagnostics.
view . Diagnostics ( diags )
if diags . HasErrors ( ) {
return 1
}
diags = nil
// Run the operation
op , err := c . RunOperation ( be , opReq )
2017-01-19 05:50:45 +01:00
if err != nil {
2021-02-18 23:23:34 +01:00
diags = diags . Append ( err )
view . Diagnostics ( diags )
2014-06-19 01:42:13 +02:00
return 1
}
2021-02-18 23:23:34 +01:00
if op . Result != backend . OperationSuccess {
return op . Result . ExitStatus ( )
}
// // Render the resource count and outputs
view . ResourceCount ( args . State . StateOutPath )
if ! c . Destroy && op . State != nil {
view . Outputs ( op . State . RootModule ( ) . OutputValues )
}
view . Diagnostics ( diags )
if diags . HasErrors ( ) {
2017-06-15 20:26:12 +02:00
return 1
}
2014-09-30 00:55:28 +02:00
2021-02-18 23:23:34 +01:00
return 0
}
func ( c * ApplyCommand ) LoadPlanFile ( path string ) ( * planfile . Reader , tfdiags . Diagnostics ) {
2021-02-02 16:35:45 +01:00
var planFile * planfile . Reader
2021-02-18 23:23:34 +01:00
var diags tfdiags . Diagnostics
// Try to load plan if path is specified
if path != "" {
var err error
planFile , err = c . PlanFile ( path )
2021-02-02 16:35:45 +01:00
if err != nil {
2021-02-18 23:23:34 +01:00
diags = diags . Append ( tfdiags . Sourceless (
tfdiags . Error ,
fmt . Sprintf ( "Failed to load %q as a plan file" , path ) ,
fmt . Sprintf ( "Error: %s" , err ) ,
) )
return nil , diags
2021-02-02 16:35:45 +01:00
}
2021-02-03 20:10:14 +01:00
// If the path doesn't look like a plan, both planFile and err will be
// nil. In that case, the user is probably trying to use the positional
// argument to specify a configuration path. Point them at -chdir.
if planFile == nil {
2021-02-18 23:23:34 +01:00
diags = diags . Append ( tfdiags . Sourceless (
tfdiags . Error ,
fmt . Sprintf ( "Failed to load %q as a plan file" , path ) ,
"The specified path is a directory, not a plan file. You can use the global -chdir flag to use this directory as the configuration root." ,
) )
return nil , diags
2021-02-03 20:10:14 +01:00
}
// If we successfully loaded a plan but this is a destroy operation,
// explain that this is not supported.
if c . Destroy {
2018-10-16 16:47:32 +02:00
diags = diags . Append ( tfdiags . Sourceless (
tfdiags . Error ,
2021-02-18 23:23:34 +01:00
"Destroy can't be called with a plan file" ,
fmt . Sprintf ( "If this plan was created using plan -destroy, apply it using:\n terraform apply %q" , path ) ,
2018-10-16 16:47:32 +02:00
) )
2021-02-18 23:23:34 +01:00
return nil , diags
2018-10-16 16:47:32 +02:00
}
}
command: validate config as part of loading it
Previously we required callers to separately call .Validate on the root
module to determine if there were any value errors, but we did that
inconsistently and would thus see crashes in some cases where later code
would try to use invalid configuration as if it were valid.
Now we run .Validate automatically after config loading, returning the
resulting diagnostics. Since we return a diagnostics here, it's possible
to return both warnings and errors.
We return the loaded module even if it's invalid, so callers are free to
ignore returned errors and try to work with the config anyway, though they
will need to be defensive against invalid configuration themselves in
that case.
As a result of this, all of the commands that load configuration now need
to use diagnostic printing to signal errors. For the moment this just
allows us to return potentially-multiple config errors/warnings in full
fidelity, but also sets us up for later when more subsystems are able
to produce rich diagnostics so we can show them all together.
Finally, this commit also removes some stale, commented-out code for the
"legacy" (pre-0.8) graph implementation, which has not been available
for some time.
2017-12-07 01:41:48 +01:00
2021-02-18 23:23:34 +01:00
return planFile , diags
}
func ( c * ApplyCommand ) PrepareBackend ( planFile * planfile . Reader , args * arguments . State ) ( backend . Enhanced , tfdiags . Diagnostics ) {
var diags tfdiags . Diagnostics
// FIXME: we need to apply the state arguments to the meta object here
// because they are later used when initializing the backend. Carving a
// path to pass these arguments to the functions that need them is
// difficult but would make their use easier to understand.
c . Meta . applyStateArguments ( args )
2021-01-29 20:39:06 +01:00
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 23:24:45 +02:00
// Load the backend
var be backend . Enhanced
var beDiags tfdiags . Diagnostics
if planFile == nil {
2021-02-18 23:23:34 +01:00
backendConfig , configDiags := c . loadBackendConfig ( "." )
2018-03-28 00:31:05 +02:00
diags = diags . Append ( configDiags )
if configDiags . HasErrors ( ) {
2021-02-18 23:23:34 +01:00
return nil , diags
2017-01-19 05:50:45 +01:00
}
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 23:24:45 +02:00
be , beDiags = c . Backend ( & BackendOpts {
Config : backendConfig ,
} )
} else {
plan , err := planFile . ReadPlan ( )
if err != nil {
diags = diags . Append ( tfdiags . Sourceless (
tfdiags . Error ,
"Failed to read plan from plan file" ,
fmt . Sprintf ( "Cannot read the plan from the given plan file: %s." , err ) ,
) )
2021-02-18 23:23:34 +01:00
return nil , diags
2018-09-30 18:29:51 +02:00
}
if plan . Backend . Config == nil {
// Should never happen; always indicates a bug in the creation of the plan file
diags = diags . Append ( tfdiags . Sourceless (
tfdiags . Error ,
"Failed to read plan from plan file" ,
2020-12-01 16:42:07 +01:00
"The given plan file does not have a valid backend configuration. This is a bug in the Terraform command that generated this plan file." ,
2018-09-30 18:29:51 +02:00
) )
2021-02-18 23:23:34 +01:00
return nil , diags
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 23:24:45 +02:00
}
be , beDiags = c . BackendForPlan ( plan . Backend )
}
2021-02-18 23:23:34 +01:00
2018-03-28 00:31:05 +02:00
diags = diags . Append ( beDiags )
if beDiags . HasErrors ( ) {
2021-02-18 23:23:34 +01:00
return nil , diags
2017-01-19 05:50:45 +01:00
}
2021-02-18 23:23:34 +01:00
return be , diags
}
func ( c * ApplyCommand ) OperationRequest ( be backend . Enhanced , view views . Apply , planFile * planfile . Reader , args * arguments . Operation ,
) ( * backend . Operation , tfdiags . Diagnostics ) {
var diags tfdiags . Diagnostics
2017-01-19 05:50:45 +01:00
2020-10-15 03:00:23 +02:00
// Applying changes with dev overrides in effect could make it impossible
// to switch back to a release version if the schema isn't compatible,
// so we'll warn about it.
2021-02-01 16:50:08 +01:00
diags = diags . Append ( c . providerDevOverrideRuntimeWarnings ( ) )
2020-10-15 03:00:23 +02:00
2017-01-19 05:50:45 +01:00
// Build the operation
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 23:24:45 +02:00
opReq := c . Operation ( be )
2021-02-18 23:23:34 +01:00
opReq . AutoApprove = args . AutoApprove
opReq . ConfigDir = "."
2018-10-31 16:45:03 +01:00
opReq . Destroy = c . Destroy
2021-02-18 23:23:34 +01:00
opReq . Hooks = view . Hooks ( )
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 23:24:45 +02:00
opReq . PlanFile = planFile
2021-02-18 23:23:34 +01:00
opReq . PlanRefresh = args . Refresh
opReq . Targets = args . Targets
2017-01-19 05:50:45 +01:00
opReq . Type = backend . OperationTypeApply
2021-02-18 23:23:34 +01:00
opReq . View = view . Operation ( )
// FIXME: To allow errors to be easily rendered, the showDiagnostics method
// accepts ...interface{}. The backend no longer needs this, as only
// tfdiags.Diagnostics values are used. Once we have migrated plan and refresh
// to use views, we can remove ShowDiagnostics and update the backend code to
// call view.Diagnostics() instead.
opReq . ShowDiagnostics = func ( vals ... interface { } ) {
var diags tfdiags . Diagnostics
diags = diags . Append ( vals ... )
view . Diagnostics ( diags )
2018-10-12 22:19:58 +02:00
}
2014-06-19 01:42:13 +02:00
2021-02-18 23:23:34 +01:00
var err error
opReq . ConfigLoader , err = c . initConfigLoader ( )
2018-03-28 00:31:05 +02:00
if err != nil {
2021-02-18 23:23:34 +01:00
diags = diags . Append ( fmt . Errorf ( "Failed to initialize config loader: %s" , err ) )
return nil , diags
command: validate config as part of loading it
Previously we required callers to separately call .Validate on the root
module to determine if there were any value errors, but we did that
inconsistently and would thus see crashes in some cases where later code
would try to use invalid configuration as if it were valid.
Now we run .Validate automatically after config loading, returning the
resulting diagnostics. Since we return a diagnostics here, it's possible
to return both warnings and errors.
We return the loaded module even if it's invalid, so callers are free to
ignore returned errors and try to work with the config anyway, though they
will need to be defensive against invalid configuration themselves in
that case.
As a result of this, all of the commands that load configuration now need
to use diagnostic printing to signal errors. For the moment this just
allows us to return potentially-multiple config errors/warnings in full
fidelity, but also sets us up for later when more subsystems are able
to produce rich diagnostics so we can show them all together.
Finally, this commit also removes some stale, commented-out code for the
"legacy" (pre-0.8) graph implementation, which has not been available
for some time.
2017-12-07 01:41:48 +01:00
}
2021-01-29 20:39:06 +01:00
2021-02-18 23:23:34 +01:00
return opReq , diags
}
2021-01-29 20:39:06 +01:00
2021-02-18 23:23:34 +01:00
func ( c * ApplyCommand ) GatherVariables ( opReq * backend . Operation , args * arguments . Vars ) tfdiags . Diagnostics {
var diags tfdiags . Diagnostics
// FIXME the arguments package currently trivially gathers variable related
// arguments in a heterogenous slice, in order to minimize the number of
// code paths gathering variables during the transition to this structure.
// Once all commands that gather variables have been converted to this
// structure, we could move the variable gathering code to the arguments
// package directly, removing this shim layer.
varArgs := args . All ( )
items := make ( [ ] rawFlag , len ( varArgs ) )
for i := range varArgs {
items [ i ] . Name = varArgs [ i ] . Name
items [ i ] . Value = varArgs [ i ] . Value
2014-07-13 18:34:35 +02:00
}
2021-02-18 23:23:34 +01:00
c . Meta . variableArgs = rawFlags { items : & items }
opReq . Variables , diags = c . collectVariableValues ( )
2014-07-13 18:34:35 +02:00
2021-02-18 23:23:34 +01:00
return diags
2014-05-24 21:27:58 +02:00
}
func ( c * ApplyCommand ) Help ( ) string {
2014-10-01 07:01:11 +02:00
if c . Destroy {
return c . helpDestroy ( )
}
return c . helpApply ( )
}
func ( c * ApplyCommand ) Synopsis ( ) string {
if c . Destroy {
2020-10-24 01:55:32 +02:00
return "Destroy previously-created infrastructure"
2014-10-01 07:01:11 +02:00
}
2020-10-24 01:55:32 +02:00
return "Create or update infrastructure"
2014-10-01 07:01:11 +02:00
}
func ( c * ApplyCommand ) helpApply ( ) string {
2014-05-24 21:27:58 +02:00
helpText := `
2020-10-24 01:55:32 +02:00
Usage : terraform apply [ options ] [ PLAN ]
2014-05-24 21:27:58 +02:00
2020-10-24 01:55:32 +02:00
Creates or updates infrastructure according to Terraform configuration
files in the current directory .
2014-09-30 00:57:35 +02:00
2020-10-24 01:55:32 +02:00
By default , Terraform will generate a new plan and present it for your
approval before taking any action . You can optionally provide a plan
file created by a previous call to "terraform plan" , in which case
Terraform will take the actions described in that plan without any
confirmation prompt .
2016-04-11 19:24:08 +02:00
2014-05-24 21:27:58 +02:00
Options :
2019-12-10 20:06:06 +01:00
- auto - approve Skip interactive approval of plan before applying .
2014-07-28 00:09:04 +02:00
- backup = path Path to backup the existing state file before
modifying . Defaults to the "-state-out" path with
2014-08-07 09:19:56 +02:00
".backup" extension . Set to "-" to disable backup .
2014-07-28 00:09:04 +02:00
2019-12-10 20:06:06 +01:00
- compact - warnings If Terraform produces any warnings that are not
accompanied by errors , show them in a more compact
form that includes only the summary messages .
2018-03-26 19:21:47 +02:00
2017-02-06 16:07:32 +01:00
- lock = true Lock the state file when locking is supported .
2017-02-03 20:15:08 +01:00
2017-04-01 22:19:59 +02:00
- lock - timeout = 0 s Duration to retry a state lock .
2014-09-29 21:46:58 +02:00
- input = true Ask for input for variables if not directly set .
2014-07-13 05:21:46 +02:00
- no - color If specified , output won ' t contain any color .
2017-02-08 20:49:08 +01:00
- parallelism = n Limit the number of parallel resource operations .
2015-10-05 22:06:08 +02:00
Defaults to 10.
2015-05-06 17:58:42 +02:00
2014-07-27 02:50:13 +02:00
- refresh = true Update state prior to checking for differences . This
has no effect if a plan file is given to apply .
2014-07-12 06:30:40 +02:00
- state = path Path to read and save state ( unless state - out
is specified ) . Defaults to "terraform.tfstate" .
2014-06-19 06:36:44 +02:00
2014-07-12 06:30:40 +02:00
- state - out = path Path to write state to that is different than
"-state" . This can be used to preserve the old
state .
2014-05-24 21:27:58 +02:00
2015-03-24 17:18:15 +01:00
- target = resource Resource to target . Operation will be limited to this
resource and its dependencies . This flag can be used
multiple times .
2014-07-18 20:37:27 +02:00
- var ' foo = bar ' Set a variable in the Terraform configuration . This
flag can be set multiple times .
- var - file = foo Set variables in the Terraform configuration from
2017-06-22 03:22:07 +02:00
a file . If "terraform.tfvars" or any ".auto.tfvars"
files are present , they will be automatically loaded .
2014-07-18 20:37:27 +02:00
2014-05-24 21:27:58 +02:00
`
return strings . TrimSpace ( helpText )
}
2014-10-01 07:01:11 +02:00
func ( c * ApplyCommand ) helpDestroy ( ) string {
helpText := `
2021-02-02 16:35:45 +01:00
Usage : terraform destroy [ options ]
2014-10-01 07:01:11 +02:00
Destroy Terraform - managed infrastructure .
Options :
- backup = path Path to backup the existing state file before
modifying . Defaults to the "-state-out" path with
".backup" extension . Set to "-" to disable backup .
2018-02-01 01:14:42 +01:00
- auto - approve Skip interactive approval before destroying .
2017-02-06 16:07:32 +01:00
- lock = true Lock the state file when locking is supported .
2017-02-03 20:15:08 +01:00
2017-04-01 22:19:59 +02:00
- lock - timeout = 0 s Duration to retry a state lock .
2014-10-01 07:01:11 +02:00
- no - color If specified , output won ' t contain any color .
2015-10-06 00:18:03 +02:00
- parallelism = n Limit the number of concurrent operations .
Defaults to 10.
2014-10-01 07:01:11 +02:00
- refresh = true Update state prior to checking for differences . This
has no effect if a plan file is given to apply .
- state = path Path to read and save state ( unless state - out
is specified ) . Defaults to "terraform.tfstate" .
- state - out = path Path to write state to that is different than
"-state" . This can be used to preserve the old
state .
2015-03-24 17:18:15 +01:00
- target = resource Resource to target . Operation will be limited to this
resource and its dependencies . This flag can be used
multiple times .
2014-10-01 07:01:11 +02:00
- var ' foo = bar ' Set a variable in the Terraform configuration . This
flag can be set multiple times .
- var - file = foo Set variables in the Terraform configuration from
2017-06-22 03:22:07 +02:00
a file . If "terraform.tfvars" or any ".auto.tfvars"
files are present , they will be automatically loaded .
2014-10-01 07:01:11 +02:00
`
return strings . TrimSpace ( helpText )
2014-06-27 23:43:23 +02:00
}