A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.hashicorp.com/terraform/cloud-docs/run/modes-and-options.mdx below:

Run modes and options in HCP Terraform | Terraform

HCP Terraform runs support many of the same modes and options available in the Terraform CLI.

The default run mode of HCP Terraform is to perform a plan and then apply it. If you have enabled auto-apply and are using a VCS or API workflow, a successful plan applies immediately. Otherwise, the run waits for user confirmation before applying.

Destroy mode instructs Terraform to create a plan which destroys all objects, regardless of configuration changes.

This option creates a speculative plan. The speculative plan shows a set of possible changes and checks them against Sentinel policies, but Terraform can not apply this plan.

You can create speculative plans with a different Terraform version than the one currently selected for a workspace. This lets you check whether your configuration is compatible with a newer Terraform version without changing the workspace settings.

Plan-only runs ignore the per-workspace run queue. Plan-only runs can proceed even if another run is in progress, can not become the workspace's current run, and do not block progress on a workspace's other runs.

Version note: Using saved plans from the CLI with HCP Terraform requires at least Terraform CLI v1.6.0.

Saved plan runs are very similar to standard plan and apply runs: they perform a plan and then optionally apply it. There are three main differences:

  1. No wait for planning. Saved plan runs ignore the per-workspace run queue during their plan and checks. Like plan-only runs, saved plans can begin planning even if another run is in progress, without blocking progress on other runs.
  2. No auto-apply. Saved plan runs are never auto-applied, even if you enabled auto-apply for the workspace. Saved plans only apply if you confirm them.
  3. Automatic discard for stale plans. If another run is applied (or the state is otherwise modified) before a saved plan run is confirmed, HCP Terraform automatically discards that saved plan. HCP Terraform may also automatically discard saved plans if they are not confirmed within a few weeks.

Saved plans are ideal for interactive CLI workflows, where you can perform many exploratory plans and then choose one to apply, or for custom continuous integration workflows where the default run queue behavior isn't suitable.

A no-operation (empty) apply enables HCP Terraform to apply a run from a plan that contains no infrastructure changes. During apply, Terraform can upgrade the state version if required. You can use this option to upgrade the state in your HCP Terraform workspace to a new Terraform version. Only some Terraform versions require this, most notably 0.13.

To make such upgrades easier, empty apply runs will always auto-apply if their plan contains no changes.

Warning: HCP Terraform cannot guarantee that a plan in this mode will produce no changes. We recommend checking the plan for drift before proceeding to the apply stage.

Hands-on: Try the Use Refresh-Only Mode to Sync Terraform State tutorial.

Version note: Refresh-only support requires a workspace using at least Terraform CLI v0.15.4.

Refresh-only mode instructs Terraform to create a plan that updates the Terraform state to match changes made to remote objects outside of Terraform. This is useful if state drift has occurred and you want to reconcile your state file to match the drifted remote objects. Applying a refresh-only run does not result in further changes to remote objects.

The -refresh=false option is used in normal planning mode to skip the default behavior of refreshing Terraform state before checking for configuration changes.

Version note: Replace support requires a workspace using at least Terraform CLI v0.15.2.

The replace option instructs Terraform to replace the object with the given resource address.

Resource Targeting is intended for exceptional circumstances only and should not be used routinely.

The usual caveats for targeting in local operations imply some additional limitations on HCP Terraform features for remote plans created with targeting:

You can disable or constrain use of targeting in a particular workspace using a Sentinel policy based on the tfrun.target_addrs value.

Version note: Support for import blocks and generating configuration requires a workspace using at least Terraform CLI v1.5.0.

When using import blocks to import existing resources, Terraform can automatically generate configuration during the plan for any imported resources that don't have an existing resource block. This option is enabled by default for runs started from the UI or from a VCS webhook.

You can find generated configuration displayed in the plan UI. If you're using the CLI workflow, Terraform will write generated configuration to the file you specify when running terraform plan.

Once Terraform has generated configuration for you, you'll need to review it, incorporate it in your Terraform configuration (including committing it to version control), then run another plan. If you try to directly apply a plan with generated configuration, the run will error.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4