content large_stringlengths 3 20.5k | url large_stringlengths 54 193 | branch large_stringclasses 4 values | source large_stringclasses 42 values | embeddings listlengths 384 384 | score float64 -0.21 0.65 |
|---|---|---|---|---|---|
tfconfig.resources.null\_resource.foo.provisioners[0].type is "local-exec" } ``` ## Namespace: Module Configuration The \*\*module configuration\*\* namespace displays data on \_module configuration\_ as it is given within a `module` block. This means that the namespace concerns itself with the contents of the declaration block (example: the `source` parameter and variable assignment keys), not the data within the module (example: any contained resources or data sources). For the latter, the module instance would need to be looked up with the [`module()` function](#root-function-module). ### Value: `source` \* \*\*Value Type:\*\* String. The `source` value within the [module configuration namespace](#namespace-module-configuration) represents the module source path as supplied to the module configuration. As an example, given the module declaration block: ```hcl module "foo" { source = "./foo" } ``` The following policy would evaluate to `true`: ```python import "tfconfig" main = rule { tfconfig.modules.foo.source is "./foo" } ``` ### Value: `version` \* \*\*Value Type:\*\* String. The `version` value within the [module configuration namespace](#namespace-module-configuration) represents the [version constraint][module-version-constraint] for modules that support it, such as modules within the [Terraform Module Registry][terraform-module-registry] or the [HCP Terraform private module registry][tfe-private-registry]. [module-version-constraint]: /terraform/language/modules#module-versions [terraform-module-registry]: https://registry.terraform.io/ [tfe-private-registry]: /terraform/cloud-docs/registry As an example, given the module declaration block: ```hcl module "foo" { source = "foo/bar" version = "~> 1.2" } ``` The following policy would evaluate to `true`: ```python import "tfconfig" main = rule { tfconfig.modules.foo.version is "~> 1.2" } ``` ### Value: `config` \* \*\*Value Type:\*\* A string-keyed map of values. -> \*\*With Terraform 0.11 or earlier\*\*, if the config value is defined as an expression (and not a static value), the value will be in its raw, non-interpolated string. \*\*With Terraform 0.12 or later\*\*, any non-static values (such as interpolated strings) are not present and [`references`](#modules-value-references) should be used instead. The `config` value within the [module configuration namespace](#namespace-module-configuration) represents the values of the keys within the module configuration. This is every key within a module declaration block except [`source`](#modules-value-source) and [`version`](#modules-value-version), which have their own values. As an example, given the module declaration block: ```hcl module "foo" { source = "./foo" bar = "baz" } ``` The following policy would evaluate to `true`: ```python import "tfconfig" main = rule { tfconfig.modules.foo.config.bar is "baz" } ``` ### Value: `references` \* \*\*Value Type:\*\* A string-keyed map of list values containing strings. -> \*\*Note:\*\* This value is only present when using Terraform 0.12 or later. The `references` value within the [module configuration namespace](#namespace-module-configuration) contains the identifiers within non-constant expressions found in [`config`](#modules-value-config). See the [documentation on `references`](#references-with-terraform-0-12) for more information. ## Namespace: Outputs The \*\*output namespace\*\* represents \_declared\_ output data within a configuration. As such, configuration for the [`value`](#outputs-value-value) attribute will be in its raw form, and not yet interpolated. For fully interpolated output values, see the [`tfstate` import][ref-tfe-sentinel-tfstate]. [ref-tfe-sentinel-tfstate]: /terraform/cloud-docs/policy-enforcement/import-reference/tfstate-v2 This namespace is indexed by output name. ### Value: `depends\_on` \* \*\*Value Type:\*\* A list of strings. The `depends\_on` value within the [output namespace](#namespace-outputs) represents any \_explicit\_ dependencies for this output. For more information, see the [depends\_on output setting][ref-depends\_on] within the general Terraform documentation. [ref-depends\_on]: /terraform/language/values/outputs#depends\_on As an example, given the following output declaration block: ```hcl output "id" { depends\_on = ["null\_resource.bar"] value = "${null\_resource.foo.id}" } ``` The following policy would evaluate to `true`: ```python import "tfconfig" main = rule { tfconfig.outputs.id.depends\_on[0] is "null\_resource.bar" } ``` ### Value: `description` \* \*\*Value Type:\*\* String. The `description` value within the [output namespace](#namespace-outputs) represents the defined description for this output. As an example, given the following output declaration block: ```hcl output "id" { description = "foobar" value = "${null\_resource.foo.id}" } ``` The following policy would evaluate to `true`: ```python import "tfconfig" main = rule { tfconfig.outputs.id.description is "foobar" } | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfconfig.mdx | main | terraform | [
-0.04061690345406532,
0.005220895167440176,
-0.08025066554546356,
0.07156158238649368,
0.00503462553024292,
-0.03213485702872276,
0.07971451431512833,
0.04517602548003197,
-0.005073751322925091,
-0.0699511170387268,
0.04651844501495361,
-0.08792562782764435,
0.043026357889175415,
0.0043485... | -0.011714 |
within the [output namespace](#namespace-outputs) represents the defined description for this output. As an example, given the following output declaration block: ```hcl output "id" { description = "foobar" value = "${null\_resource.foo.id}" } ``` The following policy would evaluate to `true`: ```python import "tfconfig" main = rule { tfconfig.outputs.id.description is "foobar" } ``` ### Value: `sensitive` \* \*\*Value Type:\*\* Boolean. The `sensitive` value within the [output namespace](#namespace-outputs) represents if this value has been marked as sensitive or not. As an example, given the following output declaration block: ```hcl output "id" { sensitive = true value = "${null\_resource.foo.id}" } ``` The following policy would evaluate to `true`: ```python import "tfconfig" main = rule { subject.outputs.id.sensitive } ``` ### Value: `value` \* \*\*Value Type:\*\* Any primitive type, list or map. The `value` value within the [output namespace](#namespace-outputs) represents the defined value for the output as declared in the configuration. Primitives will bear the implicit type of their declaration (string, int, float, or bool), and maps and lists will be represented as such. -> \*\*With Terraform 0.11 or earlier\*\*, if the config value is defined as an expression (and not a static value), the value will be in its raw, non-interpolated string. \*\*With Terraform 0.12 or later\*\*, any non-static values (such as interpolated strings) are not present and [`references`](#outputs-value-references) should be used instead. As an example, given the following output declaration block: ```hcl output "id" { value = "${null\_resource.foo.id}" } ``` With Terraform 0.11 or earlier the following policy would evaluate to `true`: ```python import "tfconfig" main = rule { tfconfig.outputs.id.value is "${null\_resource.foo.id}" } ``` ### Value: `references` \* \*\*Value Type:\*\*. List of strings. -> \*\*Note:\*\* This value is only present when using Terraform 0.12 or later. The `references` value within the [output namespace](#namespace-outputs) contains the names of any referenced identifiers when [`value`](#outputs-value-value) is a non-constant expression. As an example, given the following output declaration block: ```hcl output "id" { value = "${null\_resource.foo.id}" } ``` The following policy would evaluate to `true`: ```python import "tfconfig" main = rule { tfconfig.outputs.id.references contains "null\_resource.foo.id" } ``` ## Namespace: Providers The \*\*provider namespace\*\* represents data on the declared providers within a namespace. This namespace is indexed by provider type and \_only\_ contains data about providers when actually declared. If you are using a completely implicit provider configuration, this namespace will be empty. This namespace is populated based on the following criteria: \* The top-level namespace [`config`](#providers-value-config) and [`version`](#providers-value-version) values are populated with the configuration and version information from the default provider (the provider declaration that lacks an alias). \* Any aliased providers are added as namespaces within the [`alias`](#providers-value-alias) value. \* If a module lacks a default provider configuration, the top-level `config` and `version` values will be empty. ### Value: `alias` \* \*\*Value Type:\*\* A map of [provider namespaces](#namespace-providers), indexed by alias. The `alias` value within the [provider namespace](#namespace-providers) represents all declared [non-default provider instances][ref-tf-provider-instances] for a specific provider type, indexed by their specific alias. [ref-tf-provider-instances]: /terraform/language/providers/configuration#alias-multiple-provider-configurations The return type is a provider namespace with the data for the instance in question loaded. The `alias` key will not be available within this namespace. As an example, given the following provider declaration block: ```hcl provider "aws" { alias = "east" region = "us-east-1" } ``` The following policy would evaluate to `true`: ```python import "tfconfig" main = rule { tfconfig.providers.aws.alias.east.config.region is "us-east-1" } ``` ### Value: `config` \* \*\*Value Type:\*\* A string-keyed map of values. -> \*\*With Terraform 0.11 or earlier\*\*, if the config value is defined as an expression (and not a static value), the value will be in its raw, non-interpolated string. \*\*With Terraform 0.12 or later\*\*, | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfconfig.mdx | main | terraform | [
-0.040043629705905914,
0.05796709284186363,
-0.05222969874739647,
0.052530061453580856,
0.03586456924676895,
-0.013364746235311031,
0.0694895014166832,
-0.006750090047717094,
0.04489085450768471,
-0.06024978682398796,
-0.021168241277337074,
-0.10921646654605865,
0.10501951724290848,
0.0301... | 0.09025 |
tfconfig.providers.aws.alias.east.config.region is "us-east-1" } ``` ### Value: `config` \* \*\*Value Type:\*\* A string-keyed map of values. -> \*\*With Terraform 0.11 or earlier\*\*, if the config value is defined as an expression (and not a static value), the value will be in its raw, non-interpolated string. \*\*With Terraform 0.12 or later\*\*, any non-static values (such as interpolated strings) are not present and [`references`](#providers-value-references) should be used instead. The `config` value within the [provider namespace](#namespace-providers) represents the values of the keys within the provider's configuration, with the exception of the provider version, which is represented by the [`version`](#providers-value-version) value. [`alias`](#providers-value-alias) is also not included when the provider is aliased. As an example, given the following provider declaration block: ```hcl provider "aws" { region = "us-east-1" } ``` The following policy would evaluate to `true`: ```python import "tfconfig" main = rule { tfconfig.providers.aws.config.region is "us-east-1" } ``` ### Value: `references` \* \*\*Value Type:\*\* A string-keyed map of list values containing strings. -> \*\*Note:\*\* This value is only present when using Terraform 0.12 or later. The `references` value within the [provider namespace](#namespace-providers) contains the identifiers within non-constant expressions found in [`config`](#providers-value-config). See the [documentation on `references`](#references-with-terraform-0-12) for more information. ### Value: `version` \* \*\*Value Type:\*\* String. The `version` value within the [provider namespace](#namespace-providers) represents the explicit expected version of the supplied provider. This includes the pessimistic operator. As an example, given the following provider declaration block: ```hcl provider "aws" { version = "~> 1.34" } ``` The following policy would evaluate to `true`: ```python import "tfconfig" main = rule { tfconfig.providers.aws.version is "~> 1.34" } ``` ## Namespace: Variables The \*\*variable namespace\*\* represents \_declared\_ variable data within a configuration. As such, static data can be extracted, such as defaults, but not dynamic data, such as the current value of a variable within a plan (although this can be extracted within the [`tfplan` import][ref-tfe-sentinel-tfplan]). [ref-tfe-sentinel-tfplan]: /terraform/cloud-docs/policy-enforcement/import-reference/tfplan-v2 This namespace is indexed by variable name. ### Value: `default` \* \*\*Value Type:\*\* Any primitive type, list, map, or `null`. The `default` value within the [variable namespace](#namespace-variables) represents the default for the variable as declared in the configuration. The actual value will be as configured. Primitives will bear the implicit type of their declaration (string, int, float, or bool), and maps and lists will be represented as such. If no default is present, the value will be [`null`][ref-sentinel-null] (not to be confused with [`undefined`][ref-sentinel-undefined]). [ref-sentinel-null]: /sentinel/docs/language/spec#null [ref-sentinel-undefined]: /sentinel/docs/language/undefined As an example, given the following variable blocks: ```hcl variable "foo" { default = "bar" } variable "number" { default = 42 } ``` The following policy would evaluate to `true`: ```python import "tfconfig" default\_foo = rule { tfconfig.variables.foo.default is "bar" } default\_number = rule { tfconfig.variables.number.default is 42 } main = rule { default\_foo and default\_number } ``` ### Value: `description` \* \*\*Value Type:\*\* String. The `description` value within the [variable namespace](#namespace-variables) represents the description of the variable, as provided in configuration. As an example, given the following variable block: ```hcl variable "foo" { description = "foobar" } ``` The following policy would evaluate to `true`: ```python import "tfconfig" main = rule { tfconfig.variables.foo.description is "foobar" } ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfconfig.mdx | main | terraform | [
-0.003785186680033803,
0.04755531623959541,
0.062043558806180954,
-0.01721118576824665,
0.0086493119597435,
-0.023880772292613983,
0.051422350108623505,
-0.02899443916976452,
0.007498595397919416,
0.04444010928273201,
0.01727701909840107,
-0.1001087948679924,
0.03397601842880249,
-0.031577... | -0.036938 |
# tfplan Sentinel import reference ~> \*\*Warning:\*\* The `tfplan` import is now deprecated and will be permanently removed in August 2025. We recommend that you start using the updated [tfplan/v2](/terraform/cloud-docs/policy-enforcement/import-reference/tfplan-v2) import as soon as possible to avoid disruptions. The `tfplan/v2` import offers improved functionality and is designed to better support your policy enforcement needs. The `tfplan` import provides access to a Terraform plan. A Terraform plan is the file created as a result of `terraform plan` and is the input to `terraform apply`. The plan represents the changes that Terraform needs to make to infrastructure to reach the desired state represented by the configuration. In addition to the diff data available in the plan, there is an [`applied`](#value-applied) state available that merges the plan with the state to create the planned state after apply. Finally, this import also allows you to access the configuration files and the Terraform state at the time the plan was run. See the section on [accessing a plan's state and configuration data](#accessing-a-plan-39-s-state-and-configuration-data) for more information. @include 'tfc-package-callouts/policies.mdx' ## Namespace Overview The following is a tree view of the import namespace. For more detail on a particular part of the namespace, see below. -> Note that the root-level alias keys shown here (`data`, `path`, and `resources`) are shortcuts to a [module namespace](#namespace-module) scoped to the root module. For more details, see the section on [root namespace aliases](#root-namespace-aliases). ``` tfplan βββ module() (function) β βββ (module namespace) β βββ path ([]string) β βββ data β β βββ TYPE.NAME[NUMBER] β β βββ applied (map of keys) β β βββ diff β β βββ KEY β β βββ computed (bool) β β βββ new (string) β β βββ old (string) β βββ resources β βββ TYPE.NAME[NUMBER] β βββ applied (map of keys) β βββ destroy (bool) β βββ requires\_new (bool) β βββ diff β βββ KEY β βββ computed (bool) β βββ new (string) β βββ old (string) βββ module\_paths ([][]string) βββ terraform\_version (string) βββ variables (map of keys) β βββ data (root module alias) βββ path (root module alias) βββ resources (root module alias) β βββ config (tfconfig namespace alias) βββ state (tfstate import alias) ``` ## Namespace: Root The root-level namespace consists of the values and functions documented below. In addition to this, the root-level `data`, `path`, and `resources` keys alias to their corresponding namespaces or values within the [module namespace](#namespace-module). ### Accessing a Plan's State and Configuration Data The `config` and `state` keys alias to the [`tfconfig`][import-tfconfig] and [`tfstate`][import-tfstate] namespaces, respectively, with the data sourced from the Terraform \_plan\_ (as opposed to actual configuration and state). [import-tfconfig]: /terraform/cloud-docs/policy-enforcement/import-reference/tfconfig-v2 [import-tfstate]: /terraform/cloud-docs/policy-enforcement/import-reference/tfstate-v2 -> Note that these aliases are not represented as maps. While they will appear empty when viewed as maps, the specific import namespace keys will still be accessible. -> Note that while current versions of HCP Terraform source configuration and state data from the plan for the Terraform run in question, future versions may source data accessed through the `tfconfig` and `tfstate` imports (as opposed to `tfplan.config` and `tfplan.state`) from actual config bundles, or state as stored by HCP Terraform. When this happens, the distinction here will be useful - the data in the aliased namespaces will be the config and state data as the \_plan\_ sees it, versus the actual "physical" data. ### Function: `module()` ``` module = func(ADDR) ``` \* \*\*Return Type:\*\* A [module namespace](#namespace-module). The `module()` function in the [root namespace](#namespace-root) returns the [module namespace](#namespace-module) for a particular module address. The address must be a list and is the module address, split on the period (`.`), excluding the root module. Hence, a module | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfplan.mdx | main | terraform | [
-0.06409687548875809,
0.013351762667298317,
0.051797594875097275,
0.0035025053657591343,
0.11129549890756607,
-0.055799830704927444,
-0.011994271539151669,
-0.02888433448970318,
-0.006167371291667223,
0.10345572233200073,
-0.002045739209279418,
-0.019316652789711952,
-0.017609981819987297,
... | 0.100218 |
``` module = func(ADDR) ``` \* \*\*Return Type:\*\* A [module namespace](#namespace-module). The `module()` function in the [root namespace](#namespace-root) returns the [module namespace](#namespace-module) for a particular module address. The address must be a list and is the module address, split on the period (`.`), excluding the root module. Hence, a module with an address of simply `foo` (or `root.foo`) would be `["foo"]`, and a module within that (so address `foo.bar`) would be read as `["foo", "bar"]`. [`null`][ref-null] is returned if a module address is invalid, or if the module is not present in the diff. [ref-null]: /sentinel/docs/language/spec#null As an example, given the following module block: ```hcl module "foo" { # ... } ``` If the module contained the following content: ```hcl resource "null\_resource" "foo" { triggers = { foo = "bar" } } ``` The following policy would evaluate to `true`: ```python import "tfplan" main = rule { tfplan.module(["foo"]).resources.null\_resource.foo[0].applied.triggers.foo is "bar" } ``` ### Value: `module\_paths` \* \*\*Value Type:\*\* List of a list of strings. The `module\_paths` value within the [root namespace](#namespace-root) is a list of all of the modules within the Terraform diff for the current plan. Modules not present in the diff will not be present here, even if they are present in the configuration or state. This data is represented as a list of a list of strings, with the inner list being the module address, split on the period (`.`). The root module is included in this list, represented as an empty inner list, as long as there are changes. As an example, if the following module block was present within a Terraform configuration: ```hcl module "foo" { # ... } ``` The value of `module\_paths` would be: ``` [ [], ["foo"], ] ``` And the following policy would evaluate to `true`: ```python import "tfplan" main = rule { tfplan.module\_paths contains ["foo"] } ``` -> Note the above example only applies if the module is present in the diff. #### Iterating Through Modules Iterating through all modules to find particular resources can be useful. This [example][iterate-over-modules] shows how to use `module\_paths` with the [`module()` function](#function-module-) to find all resources of a particular type from all modules that have pending changes using the `tfplan` import. [iterate-over-modules]: /terraform/cloud-docs/policy-enforcement/sentinel#sentinel-imports ### Value: `terraform\_version` \* \*\*Value Type:\*\* String. The `terraform\_version` value within the [root namespace](#namespace-root) represents the version of Terraform used to create the plan. This can be used to enforce a specific version of Terraform in a policy check. As an example, the following policy would evaluate to `true`, as long as the plan was made with a version of Terraform in the 0.11.x series, excluding any pre-release versions (example: `-beta1` or `-rc1`): ```python import "tfplan" main = rule { tfplan.terraform\_version matches "^0\\.11\\.\\d+$" } ``` ### Value: `variables` \* \*\*Value Type:\*\* A string-keyed map of values. The `variables` value within the [root namespace](#namespace-root) represents all of the variables that were set when creating the plan. This will only contain variables set for the root module. Note that unlike the [`default`][import-tfconfig-variables-default] value in the [`tfconfig` variables namespace][import-tfconfig-variables], primitive values here are stringified, and type conversion will need to be performed to perform comparison for int, float, or boolean values. This only applies to variables that are primitives themselves and not primitives within maps and lists, which will be their original types. [import-tfconfig-variables-default]: /terraform/cloud-docs/policy-enforcement/import-reference/tfconfig-v2#value-default [import-tfconfig-variables]: /terraform/cloud-docs/policy-enforcement/import-reference/tfconfig-v2#namespace-variables If a default was accepted for the particular variable, the default value will be populated here. As an example, given the following variable blocks: ```hcl variable "foo" { default = "bar" } variable "number" { default = 42 } variable "map" { default = { foo = | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfplan.mdx | main | terraform | [
-0.0835341364145279,
-0.05687649920582771,
-0.03738628327846527,
0.06254146993160248,
0.005387785378843546,
-0.04808364808559418,
0.029561465606093407,
0.007390697952359915,
0.01699981652200222,
-0.07212518155574799,
0.04742474853992462,
-0.016232077032327652,
0.01907929964363575,
0.026739... | 0.143482 |
/terraform/cloud-docs/policy-enforcement/import-reference/tfconfig-v2#value-default [import-tfconfig-variables]: /terraform/cloud-docs/policy-enforcement/import-reference/tfconfig-v2#namespace-variables If a default was accepted for the particular variable, the default value will be populated here. As an example, given the following variable blocks: ```hcl variable "foo" { default = "bar" } variable "number" { default = 42 } variable "map" { default = { foo = "bar" number = 42 } } ``` The following policy would evaluate to `true`, if no values were entered to change these variables: ```python import "tfplan" default\_foo = rule { tfplan.variables.foo is "bar" } default\_number = rule { tfplan.variables.number is "42" } default\_map\_string = rule { tfplan.variables.map["foo"] is "bar" } default\_map\_int = rule { tfplan.variables.map["number"] is 42 } main = rule { default\_foo and default\_number and default\_map\_string and default\_map\_int } ``` ## Namespace: Module The \*\*module namespace\*\* can be loaded by calling [`module()`](#function-module-) for a particular module. It can be used to load the following child namespaces, in addition to the values documented below: \* `data` - Loads the [resource namespace](#namespace-resources-data-sources), filtered against data sources. \* `resources` - Loads the [resource namespace](#namespace-resources-data-sources), filtered against resources. ### Root Namespace Aliases The root-level `data` and `resources` keys both alias to their corresponding namespaces within the module namespace, loaded for the root module. They are the equivalent of running `module([]).KEY`. ### Value: `path` \* \*\*Value Type:\*\* List of strings. The `path` value within the [module namespace](#namespace-module) contains the path of the module that the namespace represents. This is represented as a list of strings. As an example, if the following module block was present within a Terraform configuration: ```hcl module "foo" { # ... } ``` The following policy would evaluate to `true` \_only\_ if the diff had changes for that module: ```python import "tfplan" main = rule { tfplan.module(["foo"]).path contains "foo" } ``` ## Namespace: Resources/Data Sources The \*\*resource namespace\*\* is a namespace \_type\_ that applies to both resources (accessed by using the `resources` namespace key) and data sources (accessed using the `data` namespace key). Accessing an individual resource or data source within each respective namespace can be accomplished by specifying the type, name, and resource number (as if the resource or data source had a `count` value in it) in the syntax `[resources|data].TYPE.NAME[NUMBER]`. Note that NUMBER is always needed, even if you did not use `count` in the resource. In addition, each of these namespace levels is a map, allowing you to filter based on type and name. -> The (somewhat strange) notation here of `TYPE.NAME[NUMBER]` may imply that the inner resource index map is actually a list, but it's not - using the square bracket notation over the dotted notation (`TYPE.NAME.NUMBER`) is required here as an identifier cannot start with a number. Some examples of multi-level access are below: \* To fetch all `aws\_instance.foo` resource instances within the root module, you can specify `tfplan.resources.aws\_instance.foo`. This would then be indexed by resource count index (`0`, `1`, `2`, and so on). Note that as mentioned above, these elements must be accessed using square-bracket map notation (so `[0]`, `[1]`, `[2]`, and so on) instead of dotted notation. \* To fetch all `aws\_instance` resources within the root module, you can specify `tfplan.resources.aws\_instance`. This would be indexed from the names of each resource (`foo`, `bar`, and so on), with each of those maps containing instances indexed by resource count index as per above. \* To fetch all resources within the root module, irrespective of type, use `tfplan.resources`. This is indexed by type, as shown above with `tfplan.resources.aws\_instance`, with names being the next level down, and so on. ~> When [resource targeting](/terraform/cli/commands/plan#resource-targeting) is in effect, `tfplan.resources` will only include the resources specified as targets for the | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfplan.mdx | main | terraform | [
0.001114736427552998,
0.05641666054725647,
0.03303912654519081,
0.006159094162285328,
-0.0115357656031847,
0.0027601136825978756,
0.042823273688554764,
-0.05449410900473595,
0.003804614534601569,
0.05120697617530823,
0.02212405577301979,
-0.08628201484680176,
0.03183482214808464,
0.0138662... | -0.02844 |
fetch all resources within the root module, irrespective of type, use `tfplan.resources`. This is indexed by type, as shown above with `tfplan.resources.aws\_instance`, with names being the next level down, and so on. ~> When [resource targeting](/terraform/cli/commands/plan#resource-targeting) is in effect, `tfplan.resources` will only include the resources specified as targets for the run. This may lead to unexpected outcomes if a policy expects a resource to be present in the plan. To prohibit targeted runs altogether, ensure [`tfrun.target\_addrs`](/terraform/cloud-docs/policy-enforcement/import-reference/tfrun#value-target\_addrs) is undefined or empty. Further explanation of the namespace will be in the context of resources. As mentioned, when operating on data sources, use the same syntax, except with `data` in place of `resources`. ### Value: `applied` \* \*\*Value Type:\*\* A string-keyed map of values. The `applied` value within the [resource namespace](#namespace-resources-data-sources) contains a "predicted" representation of the resource's state post-apply. It's created by merging the pending resource's diff on top of the existing data from the resource's state (if any). The map is a complex representation of these values with data going as far down as needed to represent any state values such as maps, lists, and sets. As an example, given the following resource: ```hcl resource "null\_resource" "foo" { triggers = { foo = "bar" } } ``` The following policy would evaluate to `true` if the resource was in the diff: ```python import "tfplan" main = rule { tfplan.resources.null\_resource.foo[0].applied.triggers.foo is "bar" } ``` -> Note that some values will not be available in the `applied` state because they cannot be known until the plan is actually applied. In Terraform 0.11 or earlier, these values are represented by a placeholder (the UUID value `74D93920-ED26-11E3-AC10-0800200C9A66`) and in Terraform 0.12 or later they are `undefined`. \*\*In either case\*\*, you should instead use the [`computed`](#value-computed) key within the [diff namespace](#namespace-resource-diff) to determine that a computed value will exist. -> If a resource is being destroyed, its `applied` value is omitted from the namespace and trying to fetch it will return undefined. ### Value: `diff` \* \*\*Value Type:\*\* A map of [diff namespaces](#namespace-resource-diff). The `diff` value within the [resource namespace](#namespace-resources-data-sources) contains the diff for a particular resource. Each key within the map links to a [diff namespace](#namespace-resource-diff) for that particular key. Note that unlike the [`applied`](#value-applied) value, this map is not complex; the map is only 1 level deep with each key possibly representing a diff for a particular complex value within the resource. See the below section for more details on the diff namespace, in addition to usage examples. ### Value: `destroy` \* \*\*Value Type:\*\* Boolean. The `destroy` value within the [resource namespace](#namespace-resources-data-sources) is `true` if a resource is being destroyed for \_any\_ reason, including cases where it's being deleted as part of a resource re-creation, in which case [`requires\_new`](#value-requires\_new) will also be set. As an example, given the following resource: ```hcl resource "null\_resource" "foo" { triggers = { foo = "bar" } } ``` The following policy would evaluate to `true` when `null\_resource.foo` is being destroyed: ```python import "tfplan" main = rule { tfplan.resources.null\_resource.foo[0].destroy } ``` ### Value: `requires\_new` \* \*\*Value Type:\*\* Boolean. The `requires\_new` value within the [resource namespace](#namespace-resources-data-sources) is `true` if the resource is still present in the configuration, but must be replaced to satisfy its current diff. Whenever `requires\_new` is `true`, [`destroy`](#value-destroy) is also `true`. As an example, given the following resource: ```hcl resource "null\_resource" "foo" { triggers = { foo = "bar" } } ``` The following policy would evaluate to `true` if one of the `triggers` in `null\_resource.foo` was being changed: ```python import "tfplan" main = rule { tfplan.resources.null\_resource.foo[0].requires\_new } ``` ## Namespace: Resource Diff The \*\*diff namespace\*\* is | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfplan.mdx | main | terraform | [
-0.030149834230542183,
0.032075848430395126,
0.023432569578289986,
0.00382906012237072,
0.09000377357006073,
-0.08278246223926544,
0.06570945680141449,
-0.0580616295337677,
0.07043115049600601,
0.060721371322870255,
0.005476485006511211,
-0.07478755712509155,
0.04581541568040848,
-0.023191... | 0.004083 |
resource: ```hcl resource "null\_resource" "foo" { triggers = { foo = "bar" } } ``` The following policy would evaluate to `true` if one of the `triggers` in `null\_resource.foo` was being changed: ```python import "tfplan" main = rule { tfplan.resources.null\_resource.foo[0].requires\_new } ``` ## Namespace: Resource Diff The \*\*diff namespace\*\* is a namespace that represents the diff for a specific attribute within a resource. For details on reading a particular attribute, see the [`diff`](#value-diff) value in the [resource namespace](#namespace-resources-data-sources). ### Value: `computed` \* \*\*Value Type:\*\* Boolean. The `computed` value within the [diff namespace](#namespace-resource-diff) is `true` if the resource key in question depends on another value that isn't yet known. Typically, that means the value it depends on belongs to a resource that either doesn't exist yet, or is changing state in such a way as to affect the dependent value so that it can't be known until the apply is complete. -> Keep in mind that when using `computed` with complex structures such as maps, lists, and sets, it's sometimes necessary to test the count attribute for the structure, versus a key within it, depending on whether or not the diff has marked the whole structure as computed. This is demonstrated in the example below. Count keys are `%` for maps, and `#` for lists and sets. If you are having trouble determining the type of specific field within a resource, contact the support team. As an example, given the following resource: ```hcl resource "null\_resource" "foo" { triggers = { foo = "bar" } } resource "null\_resource" "bar" { triggers = { foo\_id = "${null\_resource.foo.id}" } } ``` The following policy would evaluate to `true`, if the `id` of `null\_resource.foo` was currently not known, such as when the resource is pending creation, or is being deleted and re-created: ```python import "tfplan" main = rule { tfplan.resources.null\_resource.bar[0].diff["triggers.%"].computed } ``` ### Value: `new` \* \*\*Value Type:\*\* String. The `new` value within the [diff namespace](#namespace-resource-diff) contains the new value of a changing attribute, \_if\_ the value is known at plan time. -> `new` will be an empty string if the attribute's value is currently unknown. For more details on detecting unknown values, see [`computed`](#value-computed). Note that this value is \_always\_ a string, regardless of the actual type of the value changing. [Type conversion][ref-sentinel-type-conversion] within policy may be necessary to achieve the comparison needed. [ref-sentinel-type-conversion]: /sentinel/docs/language/values#type-conversion As an example, given the following resource: ```hcl resource "null\_resource" "foo" { triggers = { foo = "bar" } } ``` The following policy would evaluate to `true`, if the resource was in the diff and each of the concerned keys were changing to new values: ```python import "tfplan" main = rule { tfplan.resources.null\_resource.foo[0].diff["triggers.foo"].new is "bar" } ``` ### Value: `old` \* \*\*Value Type:\*\* String. The `old` value within the [diff namespace](#namespace-resource-diff) contains the old value of a changing attribute. Note that this value is \_always\_ a string, regardless of the actual type of the value changing. [Type conversion][ref-sentinel-type-conversion] within policy may be necessary to achieve the comparison needed. If the value did not exist in the previous state, `old` will always be an empty string. As an example, given the following resource: ```hcl resource "null\_resource" "foo" { triggers = { foo = "baz" } } ``` If that resource was previously in config as: ```hcl resource "null\_resource" "foo" { triggers = { foo = "bar" } } ``` The following policy would evaluate to `true`: ```python import "tfplan" main = rule { tfplan.resources.null\_resource.foo[0].diff["triggers.foo"].old is "bar" } ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfplan.mdx | main | terraform | [
-0.09685356169939041,
0.03681252524256706,
0.008274381048977375,
0.03493422269821167,
0.06570509821176529,
-0.10693689435720444,
0.11272959411144257,
-0.0725889652967453,
0.052446264773607254,
-0.0004446349339559674,
0.06401326507329941,
-0.07375504076480865,
0.08349518477916718,
-0.027561... | 0.044744 |
{ triggers = { foo = "bar" } } ``` The following policy would evaluate to `true`: ```python import "tfplan" main = rule { tfplan.resources.null\_resource.foo[0].diff["triggers.foo"].old is "bar" } ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfplan.mdx | main | terraform | [
-0.04542157053947449,
0.08054868876934052,
0.016872096806764603,
0.007234801538288593,
0.08241897821426392,
-0.09327882528305054,
0.11169548332691193,
-0.019766394048929214,
0.022047393023967743,
0.006707118358463049,
0.0636165514588356,
-0.017288483679294586,
0.052241772413253784,
-0.0055... | 0.031868 |
# `import` function reference overview This topic provides an overview of the Sentinel `import` function, which you can use to import Sentinel libraries into your custom Sentinel policies. Refer to [Define custom Sentinel policies](/terraform/cloud-docs/policy-enforcement/define-policies/custom-sentinel) for additional information about how to use the `import` function. ## Functions for Terraform You can add Sentinel the `import` function, which enables a policy to access reusable libraries, external data, and other functions. Refer to the [Sentinel imports documentation](/sentinel/docs/language/imports) for more details. HCP Terraform provides the following importable libraries to define policy rules for the plan, configuration, state, and run associated with a policy check. - [`tfplan`](/terraform/cloud-docs/policy-enforcement/import-reference/tfplan) : Provides access to a Terraform plan, which is the file created when you run the `terraform plan` command. This library is deprecated. Use `tfplanv/2` instead. - [`tfplan/v2`](/terraform/cloud-docs/policy-enforcement/import-reference/tfplan-v2): Provides access to a Terraform plan, which is the file created when you run the `terraform plan` command. - [`tfconfig`](/terraform/cloud-docs/policy-enforcement/import-reference/tfconfig): Provides access to a Terraform configuration. The configuration is the set of `.tf` files that describe the desired infrastructure state. This library is deprecated. Use `tfconfig/v2` instead. - [`tfconfig/v2`](/terraform/cloud-docs/policy-enforcement/import-reference/tfconfig-v2): Provides access to a Terraform configuration. The configuration is the set of `.tf` files that describe the desired infrastructure state. - [`tfstate`](/terraform/cloud-docs/policy-enforcement/import-reference/tfstate): Provides access to the Terraform state. Terraform uses state to map real-world resources to your configuration. This library is deprecated. Use `tfstate/v2` instead. - [`tfstate/v2`](/terraform/cloud-docs/policy-enforcement/import-reference/tfstate-v2): Provides access to the Terraform state. Terraform uses state to map real-world resources to your configuration. - [`tfrun`](/terraform/cloud-docs/policy-enforcement/import-reference/tfrun): Provides access to data associated with a run in HCP Terraform. For example, you could retrieve the run's workspace. ## Test `import` functions You can create mocks of these functions and test them using the Sentinel CLI. Refer to the following topics for additional information: - [Test Sentinel policies](/terraform/cloud-docs/policy-enforcement/test-sentinel) - [Sentinel CLI documentation](/sentinel/docs/commands) | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/index.mdx | main | terraform | [
-0.019908303394913673,
-0.0028841490857303143,
0.007713188882917166,
-0.03649124875664711,
0.06305419653654099,
0.014782475307583809,
0.0037118084728717804,
-0.026531072333455086,
-0.039265263825654984,
0.05255556479096413,
-0.004310637712478638,
-0.03926292434334755,
0.029786445200443268,
... | 0.101026 |
-> \*\*Note:\*\* This is documentation for the next version of the `tfconfig` Sentinel import, designed specifically for Terraform 0.12. This import requires Terraform 0.12 or higher, and must currently be loaded by path, using an alias, example: `import "tfconfig/v2" as tfconfig`. # tfconfig/v2 Sentinel import The `tfconfig/v2` import provides access to a Terraform configuration. The Terraform configuration is the set of `\*.tf` files that are used to describe the desired infrastructure state. Policies using the `tfconfig` import can access all aspects of the configuration: providers, resources, data sources, modules, and variables. @include 'tfc-package-callouts/policies.mdx' Some use cases for `tfconfig` include: \* \*\*Organizational naming conventions\*\*: requiring that configuration elements are named in a way that conforms to some organization-wide standard. \* \*\*Required inputs and outputs\*\*: organizations may require a particular set of input variable names across all workspaces or may require a particular set of outputs for asset management purposes. \* \*\*Enforcing particular modules\*\*: organizations may provide a number of "building block" modules and require that each workspace be built only from combinations of these modules. \* \*\*Enforcing particular providers or resources\*\*: an organization may wish to require or prevent the use of providers and/or resources so that configuration authors cannot use alternative approaches to work around policy restrictions. The data in the `tfconfig/v2` import is sourced from the JSON configuration file that is generated by the [`terraform show -json`](/terraform/cli/commands/show#json-output) command. For more information on the file format, see the [JSON Output Format](/terraform/internals/json-format) page. ## Import Overview The `tfconfig/v2` import is structured as a series of \_collections\_, keyed as a specific format, such as resource address, module address, or a specifically-formatted provider key. ``` tfconfig/v2 βββ strip\_index() (function) βββ providers β βββ (indexed by [module\_address:]provider[.alias]) β βββ provider\_config\_key (string) β βββ name (string) β βββ full\_name (string) β βββ alias (string) β βββ module\_address (string) β βββ config (block expression representation) β βββ version\_constraint (string) βββ resources β βββ (indexed by address) β βββ address (string) β βββ module\_address (string) β βββ mode (string) β βββ type (string) β βββ name (string) β βββ provider\_config\_key (string) β βββ provisioners (list) β β βββ (ordered provisioners for this resource only) β βββ config (block expression representation) β βββ count (expression representation) β βββ for\_each (expression representation) β βββ depends\_on (list of strings) βββ provisioners β βββ (indexed by resource\_address:index) β βββ resource\_address (string) β βββ type (string) β βββ index (string) β βββ config (block expression representation) βββ variables β βββ (indexed by module\_address:name) β βββ module\_address (string) β βββ name (string) β βββ default (value) β βββ description (string) βββ outputs β βββ (indexed by module\_address:name) β βββ module\_address (string) β βββ name (string) β βββ sensitive (boolean) β βββ value (expression representation) β βββ description (string) β βββ depends\_on (list of strings) βββ module\_calls βββ (indexed by module\_address:name) βββ module\_address (string) βββ name (string) βββ source (string) βββ config (block expression representation) βββ count (expression representation) βββ depends\_on (expression representation) βββ for\_each (expression representation) βββ version\_constraint (string) ``` The collections are: \* [`providers`](#the-providers-collection) - The configuration for all provider instances across all modules in the configuration. \* [`resources`](#the-resources-collection) - The configuration of all resources across all modules in the configuration. \* [`variables`](#the-variables-collection) - The configuration of all variable definitions across all modules in the configuration. \* [`outputs`](#the-outputs-collection) - The configuration of all output definitions across all modules in the configuration. \* [`module\_calls`](#the-module\_calls-collection) - The configuration of all module calls (individual [`module`](/terraform/language/modules) blocks) across all modules in the configuration. These collections are specifically designed to be used with the [`filter`](/sentinel/docs/language/collection-operations#filter-expression) quantifier expression in Sentinel, so that one can collect a list of | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfconfig-v2.mdx | main | terraform | [
-0.022201385349035263,
-0.02068931981921196,
-0.01295444369316101,
-0.032103534787893295,
0.010452162474393845,
-0.02329627238214016,
0.016292601823806763,
-0.013374322094023228,
0.025568349286913872,
0.0375109426677227,
-0.009377783164381981,
-0.05118722468614578,
-0.010941706597805023,
-... | 0.136529 |
all output definitions across all modules in the configuration. \* [`module\_calls`](#the-module\_calls-collection) - The configuration of all module calls (individual [`module`](/terraform/language/modules) blocks) across all modules in the configuration. These collections are specifically designed to be used with the [`filter`](/sentinel/docs/language/collection-operations#filter-expression) quantifier expression in Sentinel, so that one can collect a list of resources to perform policy checks on without having to write complex module or configuration traversal. As an example, the following code will return all `aws\_instance` resource types within the configuration, regardless of what module they are in: ``` all\_aws\_instances = filter tfconfig.resources as \_, r { r.mode is "managed" and r.type is "aws\_instance" } ``` You can add specific attributes to the filter to narrow the search, such as the module address. The following code would return resources in a module named `foo` only: ``` all\_aws\_instances = filter tfconfig.resources as \_, r { r.module\_address is "module.foo" and r.mode is "managed" and r.type is "aws\_instance" } ``` ### Address Differences Between `tfconfig`, `tfplan`, and `tfstate` This import deals with configuration before it is expanded into a resource graph by Terraform. As such, it is not possible to compute an index as the import is building its collections and computing addresses for resources and modules. As such, addresses found here may not always match the expanded addresses found in the [`tfplan/v2`](/terraform/cloud-docs/policy-enforcement/import-reference/tfplan-v2) and [`tfstate/v2`](/terraform/cloud-docs/policy-enforcement/import-reference/tfstate-v2) imports, specifically when [`count`](/terraform/language/resources#count-multiple-resource-instances-by-count) and [`for\_each`](/terraform/language/resources#for\_each-multiple-resource-instances-defined-by-a-map-or-set-of-strings), are used. As an example, consider a resource named `null\_resource.foo` with a count of `2` located in a module named `bar`. While there will possibly be entries in the other imports for `module.bar.null\_resource.foo[0]` and `module.bar.null\_resource.foo[1]`, in `tfconfig/v2`, there will only be a `module.bar.null\_resource.foo`. As mentioned in the start of this section, this is because configuration actually \_defines\_ this scaling, whereas \_expansion\_ actually happens when the resource graph is built, which happens as a natural part of the refresh and planning process. The `strip\_index` helper function, found in this import, can assist in removing the indexes from addresses found in the `tfplan/v2` and `tfstate/v2` imports so that data from those imports can be used to reference data in this one. ## The `strip\_index` Function The `strip\_index` helper function can be used to remove indexes from addresses found in [`tfplan/v2`](/terraform/cloud-docs/policy-enforcement/import-reference/tfplan-v2) and [`tfstate/v2`](/terraform/cloud-docs/policy-enforcement/import-reference/tfstate-v2), by removing the indexes from each resource. This can be used to help facilitate cross-import lookups for data between plan, state, and config. ``` import "tfconfig/v2" as tfconfig import "tfplan/v2" as tfplan main = rule { all filter tfplan.resource\_changes as \_, rc { rc.mode is "managed" and rc.type is "aws\_instance" } as \_, rc { tfconfig.resources[tfconfig.strip\_index(rc.address)].config.ami.constant\_value is "ami-abcdefgh012345" } } ``` ## Expression Representations Most collections in this import will have one of two kinds of \_expression representations\_. This is a verbose format for expressing a (parsed) configuration value independent of the configuration source code, which is not 100% available to a policy check in HCP Terraform. ``` (expression representation) βββ constant\_value (value) βββ references (list of strings) ``` There are two major parts to an expression representation: \* Any \_strictly constant value\_ is expressed as an expression with a `constant\_value` field. \* Any expression that requires some degree of evaluation to generate the final value - even if that value is known at plan time - is not expressed in configuration. Instead, any particular references that are made are added to the `references` field. More details on this field can be found in the [expression representation](/terraform/internals/json-format#expression-representation) section of the JSON output format documentation. For example, to determine if an output is based on a particular resource value, one could do: ``` import "tfconfig/v2" as tfconfig main = rule { tfconfig.outputs["instance\_id"].value.references is ["aws\_instance.foo"] | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfconfig-v2.mdx | main | terraform | [
-0.02836833894252777,
0.01717471331357956,
-0.028058597818017006,
0.059979017823934555,
0.08404397964477539,
-0.015228988602757454,
0.05993224307894707,
-0.06638014316558838,
0.030406109988689423,
-0.02357112057507038,
-0.02964700572192669,
-0.07096078246831894,
0.013015640899538994,
0.019... | 0.079666 |
`references` field. More details on this field can be found in the [expression representation](/terraform/internals/json-format#expression-representation) section of the JSON output format documentation. For example, to determine if an output is based on a particular resource value, one could do: ``` import "tfconfig/v2" as tfconfig main = rule { tfconfig.outputs["instance\_id"].value.references is ["aws\_instance.foo"] } ``` -> \*\*Note:\*\* The representation does not account for complex interpolations or other expressions that combine constants with other expression data. For example, the partially constant data in `"foo${var.bar}"` would be lost. ### Block Expression Representation Expanding on the above, a multi-value expression representation (such as the kind found in a [`resources`](#the-resources-collection) collection element) is similar, but the root value is a keyed map of expression representations. This is repeated until a "scalar" expression value is encountered, ie: a field that is not a block in the resource's schema. ``` (block expression representation) βββ (attribute key) βββ (child block expression representation) β βββ (...) βββ constant\_value (value) βββ references (list of strings) ``` As an example, one can validate expressions in an [`aws\_instance`](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance) resource using the following: ``` import "tfconfig/v2" as tfconfig main = rule { tfconfig.resources["aws\_instance.foo"].config.ami.constant\_value is "ami-abcdefgh012345" } ``` Note that \_nested blocks\_, sometimes known as \_sub-resources\_, will be nested in configuration as a list of blocks (reflecting their ultimate nature as a list of objects). An example would be the `aws\_instance` resource's [`ebs\_block\_device`](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance#ebs-ephemeral-and-root-block-devices) block: ``` import "tfconfig/v2" as tfconfig main = rule { tfconfig.resources["aws\_instance.foo"].config.ebs\_block\_device[0].volume\_size < 10 } ``` ## The `providers` Collection The `providers` collection is a collection representing the configurations of all provider instances across all modules in the configuration. This collection is indexed by an opaque key. This is currently `module\_address:provider.alias`, the same value as found in the `provider\_config\_key` field. `module\_address` and the colon delimiter are omitted for the root module. The `provider\_config\_key` field is also found in the `resources` collection and can be used to locate a provider that belongs to a configured resource. The fields in this collection are as follows: \* `provider\_config\_key` - The opaque configuration key, used as the index key. \* `name` - The name of the provider, ie: `aws`. \* `full\_name` - The fully-qualified name of the provider, e.g. `registry.terraform.io/hashicorp/aws`. \* `alias` - The alias of the provider, ie: `east`. Empty for a default provider. \* `module\_address` - The address of the module this provider appears in. \* `config` - A [block expression representation](#block-expression-representation) with provider configuration values. \* `version\_constraint` - The defined version constraint for this provider. ## The `resources` Collection The `resources` collection is a collection representing all of the resources found in all modules in the configuration. This collection is indexed by the resource address. The fields in this collection are as follows: \* `address` - The resource address. This is the index of the collection. \* `module\_address` - The module address that this resource was found in. \* `mode` - The resource mode, either `managed` (resources) or `data` (data sources). \* `type` - The type of resource, ie: `null\_resource` in `null\_resource.foo`. \* `name` - The name of the resource, ie: `foo` in `null\_resource.foo`. \* `provider\_config\_key` - The opaque configuration key that serves as the index of the [`providers`](#the-providers-collection) collection. \* `provisioners` - The ordered list of provisioners for this resource. The syntax of the provisioners matches those found in the [`provisioners`](#the-provisioners-collection) collection, but is a list indexed by the order the provisioners show up in the resource. \* `config` - The [block expression representation](#block-expression-representation) of the configuration values found in the resource. \* `count` - The [expression data](#expression-representations) for the `count` value in the resource. \* `for\_each` - The [expression data](#expression-representations) for the `for\_each` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfconfig-v2.mdx | main | terraform | [
-0.09554888308048248,
0.07704740017652512,
0.005110662896186113,
0.03531361743807793,
0.06974311172962189,
-0.008413729257881641,
0.02950320765376091,
-0.021065784618258476,
0.0894264504313469,
-0.012073584832251072,
-0.04268697276711464,
-0.07797187566757202,
0.024541031569242477,
0.01253... | 0.072673 |
a list indexed by the order the provisioners show up in the resource. \* `config` - The [block expression representation](#block-expression-representation) of the configuration values found in the resource. \* `count` - The [expression data](#expression-representations) for the `count` value in the resource. \* `for\_each` - The [expression data](#expression-representations) for the `for\_each` value in the resource. \* `depends\_on` - The contents of the `depends\_on` config directive, which declares explicit dependencies for this resource. ## The `provisioners` Collection The `provisioners` collection is a collection of all of the provisioners found across all resources in the configuration. While normally bound to a resource in an ordered fashion, this collection allows for the filtering of provisioners within a single expression. This collection is indexed with a key following the format `resource\_address:index`, with each field matching their respective field in the particular element below: \* `resource\_address`: The address of the resource that the provisioner was found in. This can be found in the [`resources`](#the-resources-collection) collection. \* `type`: The provisioner type, ie: `local\_exec`. \* `index`: The provisioner index as it shows up in the resource provisioner order. \* `config`: The [block expression representation](#block-expression-representation) of the configuration values in the provisioner. ## The `variables` Collection The `variables` collection is a collection of all variables across all modules in the configuration. Note that this tracks variable definitions, not values. See the [`tfplan/v2` `variables` collection](/terraform/cloud-docs/policy-enforcement/import-reference/tfplan-v2#the-variables-collection) for variable values set within a plan. This collection is indexed by the key format `module\_address:name`, with each field matching their respective name below. `module\_address` and the colon delimiter are omitted for the root module. \* `module\_address` - The address of the module the variable was found in. \* `name` - The name of the variable. \* `default` - The defined default value of the variable. \* `description` - The description of the variable. ## The `outputs` Collection The `outputs` collection is a collection of all outputs across all modules in the configuration. Note that this tracks variable definitions, not values. See the [`tfstate/v2` `outputs` collection](/terraform/cloud-docs/policy-enforcement/import-reference/tfstate-v2#the-outputs-collection) for the final values of outputs set within a state. The [`tfplan/v2` `output\_changes` collection](/terraform/cloud-docs/policy-enforcement/import-reference/tfplan-v2#the-output\_changes-collection) also contains a more complex collection of planned output changes. This collection is indexed by the key format `module\_address:name`, with each field matching their respective name below. `module\_address` and the colon delimiter are omitted for the root module. \* `module\_address` - The address of the module the output was found in. \* `name` - The name of the output. \* `sensitive` - Indicates whether or not the output was marked as [`sensitive`](/terraform/language/values/outputs#sensitive-suppressing-values-in-cli-output). \* `value` - An [expression representation](#expression-representations) for the output. \* `description` - The description of the output. \* `depends\_on` - A list of resource names that the output depends on. These are the hard-defined output dependencies as defined in the [`depends\_on`](/terraform/language/values/outputs#depends\_on-explicit-output-dependencies) field in an output declaration, not the dependencies that get derived from natural evaluation of the output expression (these can be found in the `references` field of the expression representation). ## The `module\_calls` Collection The `module\_calls` collection is a collection of all module declarations at all levels within the configuration. Note that this is the [`module`](/terraform/language/modules#calling-a-child-module) stanza in any particular configuration, and not the module itself. Hence, a declaration for `module.foo` would actually be declared in the root module, which would be represented by a blank field in `module\_address`. This collection is indexed by the key format `module\_address:name`, with each field matching their respective name below. `module\_address` and the colon delimiter are omitted for the root module. \* `module\_address` - The address of the module the declaration was found in. \* `name` - The name of the module. \* `source` - The | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfconfig-v2.mdx | main | terraform | [
-0.062101561576128006,
0.04839523509144783,
0.001620491617359221,
0.06675222516059875,
0.08678627014160156,
-0.01311059482395649,
0.08463161438703537,
-0.07069575786590576,
0.03886392340064049,
-0.011342168785631657,
0.00997111201286316,
-0.0054817721247673035,
0.051000695675611496,
-0.007... | 0.08467 |
indexed by the key format `module\_address:name`, with each field matching their respective name below. `module\_address` and the colon delimiter are omitted for the root module. \* `module\_address` - The address of the module the declaration was found in. \* `name` - The name of the module. \* `source` - The contents of the `source` field. \* `config` - A [block expression representation](#block-expression-representation) for all parameter values sent to the module. \* `count` - An [expression representation](#expression-representations) for the `count` field. \* `depends\_on`: An [expression representation](#expression-representations) for the `depends\_on` field. \* `for\_each` - An [expression representation](#expression-representations) for the `for\_each` field. \* `version\_constraint` - The string value found in the `version` field of the module declaration. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfconfig-v2.mdx | main | terraform | [
-0.014952786266803741,
0.01160228531807661,
-0.04759687930345535,
0.06183525174856186,
-0.0009574988507665694,
0.01727943681180477,
0.06272298842668533,
-0.007273306138813496,
0.01559393759816885,
-0.07141625136137009,
-0.010289841331541538,
-0.02433437667787075,
0.06284923851490021,
-0.06... | 0.105789 |
-> \*\*Note:\*\* This is documentation for the next version of the `tfplan` Sentinel import, designed specifically for Terraform 0.12. This import requires Terraform 0.12 or higher, and must currently be loaded by path, using an alias, example: `import "tfplan/v2" as tfplan`. # tfplan/v2 Sentinel import The `tfplan/v2` import provides access to a Terraform plan. A Terraform plan is the file created as a result of `terraform plan` and is the input to `terraform apply`. The plan represents the changes that Terraform needs to make to infrastructure to reach the desired state represented by the configuration. @include 'tfc-package-callouts/policies.mdx' In addition to the diff data available in the plan, there is a "planned state" that is available through this import, via the [`planned\_values`](#the-planned\_values-collection) collection. This collection presents the Terraform state as how it might look after the plan data is applied, but is not guaranteed to be the final state. The data in the `tfplan/v2` import is sourced from the JSON configuration file that is generated by the [`terraform show -json`](/terraform/cli/commands/show#json-output) command. For more information on the file format, see the [JSON Output Format](/terraform/internals/json-format) page. The entirety of the JSON output file is exposed as a Sentinel map via the [`raw`](#the-raw-collection) collection. This allows direct, low-level access to the JSON data, but should only be used in complex situations where the higher-level collections do not serve the purpose. ## Import Overview The `tfplan/v2` import is structured as a series of \_collections\_, keyed as a specific format depending on the collection. ``` tfplan/v2 βββ terraform\_version (string) βββ variables β βββ (indexed by name) β βββ name (string) β βββ value (value) βββ planned\_values β βββ outputs (tfstate/v2 outputs representation) β βββ resources (tfstate/v2 resources representation) βββ resource\_changes β βββ (indexed by address[:deposed]) β βββ address (string) β βββ module\_address (string) β βββ mode (string) β βββ type (string) β βββ name (string) β βββ index (float (number) or string) β βββ provider\_name (string) β βββ deposed (string) β βββ change (change representation) βββ resource\_drift β βββ (indexed by address[:deposed]) β βββ address (string) β βββ module\_address (string) β βββ mode (string) β βββ type (string) β βββ name (string) β βββ index (float (number) or string) β βββ provider\_name (string) β βββ deposed (string) β βββ change (change representation) βββ output\_changes β βββ (indexed by name) β βββ name (string) β βββ change (change representation) βββ raw (map) ``` The collections are: \* [`variables`](#the-variables-collection) - The values of variables that have been set in the plan itself. This collection only contains variables set in the root module. \* [`planned\_values`](#the-planned\_values-collection) - The state representation of \_planned values\_, or an estimation of what the state will look like after the plan is applied. \* [`resource\_changes`](#the-resource\_changes-and-resource\_drift-collections) - The set of change operations for resources and data sources within this plan. \* [`resource\_drift`](#the-resource\_changes-and-resource\_drift-collections) - A description of the changes Terraform detected when it compared the most recent state to the prior saved state. \* [`output\_changes`](#the-output\_changes-collection) - The changes to outputs within this plan. This collection only contains outputs set in the root module. \* [`raw`](#the-raw-collection) - Access to the raw plan data as stored by HCP Terraform. These collections are specifically designed to be used with the [`filter`](/sentinel/docs/language/collection-operations#filter-expression) quantifier expression in Sentinel, so that one can collect a list of resources to perform policy checks on without having to write complex discovery code. As an example, the following code will return all `aws\_instance` resource changes, across all modules in the plan: ``` all\_aws\_instances = filter tfplan.resource\_changes as \_, rc { rc.mode is "managed" and rc.type is "aws\_instance" } ``` You can add specific attributes to the filter | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfplan-v2.mdx | main | terraform | [
-0.05394239351153374,
0.04310164973139763,
0.044737424701452255,
-0.024787645787000656,
0.03549912944436073,
-0.07212135195732117,
0.010386945679783821,
-0.018259476870298386,
0.03382107987999916,
0.08057025820016861,
0.0005765420501120389,
-0.047507524490356445,
-0.014790565706789494,
-0.... | 0.111205 |
having to write complex discovery code. As an example, the following code will return all `aws\_instance` resource changes, across all modules in the plan: ``` all\_aws\_instances = filter tfplan.resource\_changes as \_, rc { rc.mode is "managed" and rc.type is "aws\_instance" } ``` You can add specific attributes to the filter to narrow the search, such as the module address, or the operation being performed. The following code would return resources in a module named `foo` only, and further narrow the search down to only resources that were being created: ``` all\_aws\_instances = filter tfplan.resource\_changes as \_, rc { rc.module\_address is "module.foo" and rc.mode is "managed" and rc.type is "aws\_instance" and rc.change.actions is ["create"] } ``` ### Change Representation Certain collections in this import contain a \_change representation\_, an object with details about changes to a particular entity, such as a resource (within the [`resource\_changes`](#the-resource\_changes-collection) collection), or output (within the [`output\_changes`](#the-output\_changes-collection) collection). ``` (change representation) βββ actions (list) βββ before (value, or map) βββ after (value, or map) βββ after\_unknown (boolean, or map of booleans) ``` This change representation contains the following fields: \* `actions` - A list of actions being carried out for this change. The order is important, for example a regular replace operation is denoted by `["delete", "create"]`, but a [`create\_before\_destroy`](/terraform/language/meta-arguments/lifecycle#create\_before\_destroy) resource will have an operation order of `["create", "delete"]`. \* `before` - The representation of the resource data object value before the action. For create-only actions, this is unset. For no-op actions, this value will be identical with `after`. \* `after` - The representation of the resource data object value after the action. For delete-only actions, this is unset. For no-op actions, this value will be identical with `before`. Note that unknown values will not show up in this field. \* `after\_unknown` - A deep object of booleans that denotes any values that are unknown in a resource. These values were previously referred to as "computed" values. If the value cannot be found in this map, then its value should be available within `after`, so long as the operation supports it. #### Actions As mentioned above, actions show up within the `actions` field of a change representation and indicate the type of actions being performed as part of the change, and the order that they are being performed in. The current list of actions are as follows: \* `create` - The action will create the associated entity. Depending on the order this appears in, the entity may be created alongside a copy of the entity before replacing it. \* `read` - The action will read the associated entity. In practice, seeing this change type should be rare, as reads generally happen before a plan is executed (usually during a refresh). \* `update` - The action will update the associated entity in a way that alters its state in some way. \* `delete` - The action will remove the associated entity, deleting any applicable state and associated real resources or infrastructure. \* `no-op` - No action will be performed on the associated entity. The `actions` field is a list, as some real-world actions are actually a composite of more than one primitive action. At this point in time, this is generally only applicable to resource replacement, in which the following action orders apply: \* \*\*Normal replacement:\*\* `["delete", "create"]` - Applies to default lifecycle configurations. \* \*\*Create-before-destroy:\*\* `["create", "delete"]` - Applies when [`create\_before\_destroy`](/terraform/language/meta-arguments/lifecycle#create\_before\_destroy) is used in a lifecycle configuration. Note that, in most situations, the plan will list all "changes", including no-op changes. This makes filtering on change type crucial to the accurate selection of data if you are | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfplan-v2.mdx | main | terraform | [
-0.052092768251895905,
0.08542500436306,
-0.021616963669657707,
0.054608579725027084,
0.09180734306573868,
-0.019340800121426582,
0.08985361456871033,
-0.07106125354766846,
0.03368840366601944,
-0.011767405085265636,
0.00013926016981713474,
-0.07078837603330612,
0.049088310450315475,
0.008... | 0.038971 |
- Applies to default lifecycle configurations. \* \*\*Create-before-destroy:\*\* `["create", "delete"]` - Applies when [`create\_before\_destroy`](/terraform/language/meta-arguments/lifecycle#create\_before\_destroy) is used in a lifecycle configuration. Note that, in most situations, the plan will list all "changes", including no-op changes. This makes filtering on change type crucial to the accurate selection of data if you are concerned with the state change of a particular resource. To filter on a change type, use exact list comparison. For example, the following example from the [Import Overview](#import-overview) filters on exactly the resources being created \_only\_: ``` all\_aws\_instances = filter tfplan.resource\_changes as \_, rc { rc.module\_address is "module.foo" and rc.mode is "managed" and rc.type is "aws\_instance" and rc.change.actions is ["create"] } ``` #### `before`, `after`, and `after\_unknown` The exact attribute changes for a particular operation are outlined in the `before` and `after` attributes. Depending on the entity being operated on, this will either be a map (as with [`resource\_changes`](#the-resource\_changes-collection)) or a singular value (as with [`output\_changes`](#the-output\_changes-collection)). What you can expect in these fields varies depending on the operation: \* For fresh create operations, `before` will generally be `null`, and `after` will contain the data you can expect to see after the change. \* For full delete operations, this will be reversed - `before` will contain data, and `after` will be `null`. \* Update or replace operations will have data in both fields relevant to their states before and after the operation. \* No-op operations should have identical data in `before` and `after`. For resources, if a field cannot be found in `after`, it generally means one of two things: \* The attribute does not exist in the resource schema. Generally, known attributes that do not have a value will show up as `null` or otherwise empty in `after`. \* The attribute is \_unknown\_, that is, it was unable to be determined at plan time and will only be available after apply-time values have been able to be calculated. In the latter case, there should be a value for the particular attribute in `after\_unknown`, which can be checked to assert that the value is indeed unknown, versus invalid: ``` import "tfplan/v2" as tfplan no\_unknown\_amis = rule { all filter tfplan.resource\_changes as \_, rc { rc.module\_address is "module.foo" and rc.mode is "managed" and rc.type is "aws\_instance" and rc.change.actions is ["create"] } as \_, rc { rc.change.after\_unknown.ami else false is false } } ``` For output changes, `after\_unknown` will simply be `true` if the value won't be known until the plan is applied. ## The `terraform\_version` Value The top-level `terraform\_version` value in this import gives the Terraform version that made the plan. This can be used to do version validation. ``` import "tfplan/v2" as tfplan import "strings" v = strings.split(tfplan.terraform\_version, ".") version\_major = int(v[1]) version\_minor = int(v[2]) main = rule { version\_major is 12 and version\_minor >= 19 } ``` -> \*\*NOTE:\*\* The above example will give errors when working with pre-release versions (example: `0.12.0beta1`). Future versions of this import will include helpers to assist with processing versions that will account for these kinds of exceptions. ## The `variables` Collection The `variables` collection is a collection of the variables set in the root module when creating the plan. This collection is indexed on the name of the variable. The valid values are: \* `name` - The name of the variable, also used as the collection key. \* `value` - The value of the variable assigned during the plan. ## The `planned\_values` Collection The `planned\_values` collection is a special collection in that it contains two fields that alias to state collections with the \_planned\_ state set. This is the best prediction of what the | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfplan-v2.mdx | main | terraform | [
-0.051121462136507034,
0.08688022196292877,
0.045557960867881775,
-0.01097483653575182,
0.09553036838769913,
-0.05630125850439072,
0.08252564072608948,
-0.08909790217876434,
0.060810305178165436,
0.05000657960772514,
-0.009907620027661324,
-0.0577496737241745,
0.003558229887858033,
0.02366... | 0.014892 |
the collection key. \* `value` - The value of the variable assigned during the plan. ## The `planned\_values` Collection The `planned\_values` collection is a special collection in that it contains two fields that alias to state collections with the \_planned\_ state set. This is the best prediction of what the state will look like after the plan is executed. The two fields are: \* `outputs` - The prediction of what output values will look like after the state is applied. For more details on the structure of this collection, see the [`outputs`](/terraform/cloud-docs/policy-enforcement/import-reference/tfstate-v2#the-outputs-collection) collection in the [`tfstate/v2`](/terraform/cloud-docs/policy-enforcement/import-reference/tfstate-v2) documentation. \* `resources` - The prediction of what resource values will look like after the state is applied. For more details on the structure of this collection, see the [`resources`](/terraform/cloud-docs/policy-enforcement/import-reference/tfstate-v2#the-resources-collection) collection in the [`tfstate/v2`](/terraform/cloud-docs/policy-enforcement/import-reference/tfstate-v2) documentation. -> \*\*NOTE:\*\* Unknown values are omitted from the `planned\_values` state representations, regardless of whether or not they existed before. Use [`resource\_changes`](#the-resource\_changes-collection) if awareness of unknown data is important. ## The `resource\_changes` and `resource\_drift` Collections The `resource\_changes` and `resource\_drift` collections are a set of change operations for resources and data sources within this plan. The `resource\_drift` collection provides a description of the changes Terraform detected when it compared the most recent state to the prior saved state. The `resource\_changes` collection includes all resources that have been found in the configuration and state, regardless of whether or not they are changing. ~> When [resource targeting](/terraform/cli/commands/plan#resource-targeting) is in effect, the `resource\_changes` collection will only include the resources specified as targets for the run. This may lead to unexpected outcomes if a policy expects a resource to be present in the plan. To prohibit targeted runs altogether, ensure [`tfrun.target\_addrs`](/terraform/cloud-docs/policy-enforcement/import-reference/tfrun#value-target\_addrs) is undefined or empty. This collection is indexed on the complete resource address as the key. If `deposed` is non-empty, it is appended to the end, and may look something like `aws\_instance.foo:deposed-abc123`. An element contains the following fields: \* `address` - The absolute resource address - also the key for the collection's index, if `deposed` is empty. \* `module\_address` - The module portion of the absolute resource address. \* `mode` - The resource mode, either `managed` (resources) or `data` (data sources). \* `type` - The resource type, example: `aws\_instance` for `aws\_instance.foo`. \* `name` - The resource name, example: `foo` for `aws\_instance.foo`. \* `index` - The resource index. Can be either a number or a string. \* `provider\_name` - The name of the provider this resource belongs to. This allows the provider to be interpreted unambiguously in the unusual situation where a provider offers a resource type whose name does not start with its own name, such as the `googlebeta` provider offering `google\_compute\_instance`. -> \*\*Note:\*\* Starting with Terraform 0.13, the `provider\_name` field contains the \_full\_ source address to the provider in the Terraform Registry. Example: `registry.terraform.io/hashicorp/null` for the null provider. \* `deposed` - An identifier used during replacement operations, and can be used to identify the exact resource being replaced in state. \* `change` - The data describing the change that will be made to this resource. For more details, see [Change Representation](#change-representation). ## The `output\_changes` Collection The `output\_changes` collection is a collection of the change operations for outputs within this plan. Only outputs for the root module are included. This collection is indexed by the name of the output. The fields in a collection value are below: \* `name` - The name of the output, also the index key. \* `change` - The data describing the change that will be made to this output. For more details, see [Change Representation](#change-representation). ## The `raw` Collection The `raw` collection exposes the raw, unprocessed plan data, direct | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfplan-v2.mdx | main | terraform | [
-0.05057692900300026,
0.06916394829750061,
-0.024026699364185333,
0.0008602701709605753,
0.02071167342364788,
-0.005549078807234764,
0.025371968746185303,
-0.06385510414838791,
0.06998927891254425,
0.05184057727456093,
-0.006327833514660597,
-0.06209465116262436,
0.06089325249195099,
-0.05... | 0.090259 |
value are below: \* `name` - The name of the output, also the index key. \* `change` - The data describing the change that will be made to this output. For more details, see [Change Representation](#change-representation). ## The `raw` Collection The `raw` collection exposes the raw, unprocessed plan data, direct from the data stored by HCP Terraform. This is the same data that is produced by [`terraform show -json`](/terraform/cli/commands/show#json-output) on the plan file for the run this policy check is attached to. Use of this data is only recommended in expert situations where the data the collections present may not exactly serve the needs of the policy. For more information on the file format, see the [JSON Output Format](/terraform/internals/json-format) page. -> \*\*NOTE:\*\* Although designed to be relatively stable, the actual makeup for the JSON output format is a Terraform CLI concern and as such not managed by HCP Terraform. Use at your own risk, follow the [Terraform CLI project](https://github.com/hashicorp/terraform), and watch the file format documentation for any changes. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfplan-v2.mdx | main | terraform | [
-0.04709022864699364,
0.1126607209444046,
0.007079934701323509,
-0.03387277573347092,
0.0003248772118240595,
0.0040377406403422356,
-0.03954034298658371,
-0.06217649206519127,
-0.004732224624603987,
0.022422460839152336,
0.019566088914871216,
-0.07495642453432083,
0.04301362484693527,
-0.0... | 0.021836 |
# Import: tfstate ~> \*\*Warning:\*\* The `tfstate` import is now deprecated and will be permanently removed in August 2025. We recommend that you start using the updated [tfstate/v2](/terraform/cloud-docs/policy-enforcement/import-reference/tfstate-v2) import as soon as possible to avoid disruptions. The `tfstate/v2` import offers improved functionality and is designed to better support your policy enforcement needs. The `tfstate` import provides access to the Terraform state. @include 'tfc-package-callouts/policies.mdx' The \_state\_ is the data that Terraform has recorded about a workspace at a particular point in its lifecycle, usually after an apply. You can read more general information about how Terraform uses state [here][ref-tf-state]. [ref-tf-state]: /terraform/language/state -> \*\*Note:\*\* Since HCP Terraform currently only supports policy checks at plan time, the usefulness of this import is somewhat limited, as it will usually give you the state \_prior\_ to the plan the policy check is currently being run for. Depending on your needs, you may find the [`applied`](/terraform/cloud-docs/policy-enforcement/import-reference/tfplan-v2#value-applied) collection in `tfplan` more useful, which will give you a \_predicted\_ state by applying plan data to the data found here. The one exception to this rule is \_data sources\_, which will always give up to date data here, as long as the data source could be evaluated at plan time. ## Namespace Overview The following is a tree view of the import namespace. For more detail on a particular part of the namespace, see below. -> Note that the root-level alias keys shown here (`data`, `outputs`, `path`, and `resources`) are shortcuts to a [module namespace](#namespace-module) scoped to the root module. For more details, see the section on [root namespace aliases](#root-namespace-aliases). ``` tfstate βββ module() (function) β βββ (module namespace) β βββ path ([]string) β βββ data β β βββ TYPE.NAME[NUMBER] β β βββ attr (map of keys) β β βββ depends\_on ([]string) β β βββ id (string) β β βββ tainted (boolean) β βββ outputs (root module only in TF 0.12 or later) β β βββ NAME β β βββ sensitive (bool) β β βββ type (string) β β βββ value (value) β βββ resources β βββ TYPE.NAME[NUMBER] β βββ attr (map of keys) β βββ depends\_on ([]string) β βββ id (string) β βββ tainted (boolean) β βββ module\_paths ([][]string) βββ terraform\_version (string) β βββ data (root module alias) βββ outputs (root module alias) βββ path (root module alias) βββ resources (root module alias) ``` ## Namespace: Root The root-level namespace consists of the values and functions documented below. In addition to this, the root-level `data`, `outputs`, `path`, and `resources` keys alias to their corresponding namespaces or values within the [module namespace](#namespace-module). ### Function: `module()` ``` module = func(ADDR) ``` \* \*\*Return Type:\*\* A [module namespace](#namespace-module). The `module()` function in the [root namespace](#namespace-root) returns the [module namespace](#namespace-module) for a particular module address. The address must be a list and is the module address, split on the period (`.`), excluding the root module. Hence, a module with an address of simply `foo` (or `root.foo`) would be `["foo"]`, and a module within that (so address `foo.bar`) would be read as `["foo", "bar"]`. [`null`][ref-null] is returned if a module address is invalid, or if the module is not present in the state. [ref-null]: /sentinel/docs/language/spec#null As an example, given the following module block: ```hcl module "foo" { # ... } ``` If the module contained the following content: ```hcl resource "null\_resource" "foo" { triggers = { foo = "bar" } } ``` The following policy would evaluate to `true` if the resource was present in the state: ```python import "tfstate" main = rule { tfstate.module(["foo"]).resources.null\_resource.foo[0].attr.triggers.foo is "bar" } ``` ### Value: `module\_paths` \* \*\*Value Type:\*\* List of a list of strings. The `module\_paths` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfstate.mdx | main | terraform | [
-0.025954974815249443,
0.010516108945012093,
0.034797269850969315,
-0.04610768333077431,
0.06678874045610428,
0.004703056998550892,
0.03694656863808632,
-0.06360868364572525,
-0.00002798072455334477,
0.06910569220781326,
-0.032324548810720444,
-0.06741432845592499,
0.03264797478914261,
-0.... | 0.073588 |
triggers = { foo = "bar" } } ``` The following policy would evaluate to `true` if the resource was present in the state: ```python import "tfstate" main = rule { tfstate.module(["foo"]).resources.null\_resource.foo[0].attr.triggers.foo is "bar" } ``` ### Value: `module\_paths` \* \*\*Value Type:\*\* List of a list of strings. The `module\_paths` value within the [root namespace](#namespace-root) is a list of all of the modules within the Terraform state at plan-time. Modules not present in the state will not be present here, even if they are present in the configuration or the diff. This data is represented as a list of a list of strings, with the inner list being the module address, split on the period (`.`). The root module is included in this list, represented as an empty inner list, as long as it is present in state. As an example, if the following module block was present within a Terraform configuration: ```hcl module "foo" { # ... } ``` The value of `module\_paths` would be: ``` [ [], ["foo"], ] ``` And the following policy would evaluate to `true`: ```python import "tfstate" main = rule { tfstate.module\_paths contains ["foo"] } ``` -> Note the above example only applies if the module is present in the state. #### Iterating Through Modules Iterating through all modules to find particular resources can be useful. This [example][iterate-over-modules] shows how to use `module\_paths` with the [`module()` function](#function-module-) to find all resources of a particular type from all modules using the `tfplan` import. By changing `tfplan` in this function to `tfstate`, you could make a similar function find all resources of a specific type in the current state. [iterate-over-modules]: /terraform/cloud-docs/policy-enforcement/sentinel#sentinel-imports ### Value: `terraform\_version` \* \*\*Value Type:\*\* String. The `terraform\_version` value within the [root namespace](#namespace-root) represents the version of Terraform in use when the state was saved. This can be used to enforce a specific version of Terraform in a policy check. As an example, the following policy would evaluate to `true` as long as the state was made with a version of Terraform in the 0.11.x series, excluding any pre-release versions (example: `-beta1` or `-rc1`): ```python import "tfstate" main = rule { tfstate.terraform\_version matches "^0\\.11\\.\\d+$" } ``` -> \*\*NOTE:\*\* This value is also available via the [`tfplan`](/terraform/cloud-docs/policy-enforcement/import-reference/tfplan-v2) import, which will be more current when a policy check is run against a plan. It's recommended you use the value in `tfplan` until HCP Terraform supports policy checks in other stages of the workspace lifecycle. See the [`terraform\_version`][import-tfplan-terraform-version] reference within the `tfplan` import for more details. [import-tfplan-terraform-version]: /terraform/cloud-docs/policy-enforcement/import-reference/tfplan-v2#value-terraform\_version ## Namespace: Module The \*\*module namespace\*\* can be loaded by calling [`module()`](#function-module-) for a particular module. It can be used to load the following child namespaces, in addition to the values documented below: \* `data` - Loads the [resource namespace](#namespace-resources-data-sources), filtered against data sources. \* `outputs` - Loads the [output namespace](#namespace-outputs), which supply the outputs present in this module's state. Note that with Terraform 0.12 or later, this value is only available for the root namespace. \* `resources` - Loads the [resource namespace](#namespace-resources-data-sources), filtered against resources. ### Root Namespace Aliases The root-level `data`, `outputs`, and `resources` keys both alias to their corresponding namespaces within the module namespace, loaded for the root module. They are the equivalent of running `module([]).KEY`. ### Value: `path` \* \*\*Value Type:\*\* List of strings. The `path` value within the [module namespace](#namespace-module) contains the path of the module that the namespace represents. This is represented as a list of strings. As an example, if the following module block was present within a Terraform configuration: ```hcl module "foo" { # ... } ``` The following policy would | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfstate.mdx | main | terraform | [
-0.033358387649059296,
0.01960417442023754,
0.06420700997114182,
0.03153739124536514,
0.08174040913581848,
-0.058276984840631485,
0.06738080084323883,
-0.061828941106796265,
0.04538555070757866,
0.03763439133763313,
0.017638031393289566,
-0.05828295275568962,
0.08997729420661926,
-0.011919... | 0.070282 |
`path` value within the [module namespace](#namespace-module) contains the path of the module that the namespace represents. This is represented as a list of strings. As an example, if the following module block was present within a Terraform configuration: ```hcl module "foo" { # ... } ``` The following policy would evaluate to `true`, \_only\_ if the module was present in the state: ```python import "tfstate" main = rule { tfstate.module(["foo"]).path contains "foo" } ``` ## Namespace: Resources/Data Sources The \*\*resource namespace\*\* is a namespace \_type\_ that applies to both resources (accessed by using the `resources` namespace key) and data sources (accessed using the `data` namespace key). Accessing an individual resource or data source within each respective namespace can be accomplished by specifying the type, name, and resource number (as if the resource or data source had a `count` value in it) in the syntax `[resources|data].TYPE.NAME[NUMBER]`. Note that NUMBER is always needed, even if you did not use `count` in the resource. In addition, each of these namespace levels is a map, allowing you to filter based on type and name. -> The (somewhat strange) notation here of `TYPE.NAME[NUMBER]` may imply that the inner resource index map is actually a list, but it's not - using the square bracket notation over the dotted notation (`TYPE.NAME.NUMBER`) is required here as an identifier cannot start with number. Some examples of multi-level access are below: \* To fetch all `aws\_instance.foo` resource instances within the root module, you can specify `tfstate.resources.aws\_instance.foo`. This would then be indexed by resource count index (`0`, `1`, `2`, and so on). Note that as mentioned above, these elements must be accessed using square-bracket map notation (so `[0]`, `[1]`, `[2]`, and so on) instead of dotted notation. \* To fetch all `aws\_instance` resources within the root module, you can specify `tfstate.resources.aws\_instance`. This would be indexed from the names of each resource (`foo`, `bar`, and so on), with each of those maps containing instances indexed by resource count index as per above. \* To fetch all resources within the root module, irrespective of type, use `tfstate.resources`. This is indexed by type, as shown above with `tfstate.resources.aws\_instance`, with names being the next level down, and so on. Further explanation of the namespace will be in the context of resources. As mentioned, when operating on data sources, use the same syntax, except with `data` in place of `resources`. ### Value: `attr` \* \*\*Value Type:\*\* A string-keyed map of values. The `attr` value within the [resource namespace](#namespace-resources-data-sources) is a direct mapping to the state of the resource. The map is a complex representation of these values with data going as far down as needed to represent any state values such as maps, lists, and sets. As an example, given the following resource: ```hcl resource "null\_resource" "foo" { triggers = { foo = "bar" } } ``` The following policy would evaluate to `true` if the resource was in the state: ```python import "tfstate" main = rule { tfstate.resources.null\_resource.foo[0].attr.triggers.foo is "bar" } ``` ### Value: `depends\_on` \* \*\*Value Type:\*\* A list of strings. The `depends\_on` value within the [resource namespace](#namespace-resources-data-sources) contains the dependencies for the resource. This is a list of full resource addresses, relative to the module (example: `null\_resource.foo`). As an example, given the following resources: ```hcl resource "null\_resource" "foo" { triggers = { foo = "bar" } } resource "null\_resource" "bar" { # ... depends\_on = [ "null\_resource.foo", ] } ``` The following policy would evaluate to `true` if the resource was in the state: ```python import "tfstate" main = rule { tfstate.resources.null\_resource.bar[0].depends\_on contains "null\_resource.foo" } ``` ### Value: `id` \* \*\*Value Type:\*\* String. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfstate.mdx | main | terraform | [
-0.05502140149474144,
0.0243468526750803,
-0.005822137929499149,
0.033554740250110626,
0.035532910376787186,
-0.04482104629278183,
0.08626363426446915,
-0.05178019031882286,
0.046871840953826904,
-0.003278611460700631,
-0.020837103947997093,
-0.08112768828868866,
0.08579820394515991,
0.019... | 0.057605 |
= "bar" } } resource "null\_resource" "bar" { # ... depends\_on = [ "null\_resource.foo", ] } ``` The following policy would evaluate to `true` if the resource was in the state: ```python import "tfstate" main = rule { tfstate.resources.null\_resource.bar[0].depends\_on contains "null\_resource.foo" } ``` ### Value: `id` \* \*\*Value Type:\*\* String. The `id` value within the [resource namespace](#namespace-resources-data-sources) contains the id of the resource. -> \*\*NOTE:\*\* The example below uses a \_data source\_ here because the [`null\_data\_source`][ref-tf-null-data-source] data source gives a static ID, which makes documenting the example easier. As previously mentioned, data sources share the same namespace as resources, but need to be loaded with the `data` key. For more information, see the [synopsis](#namespace-resources-data-sources) for the namespace itself. [ref-tf-null-data-source]: https://registry.terraform.io/providers/hashicorp/null/latest/docs/data-sources/data\_source As an example, given the following data source: ```hcl data "null\_data\_source" "foo" { # ... } ``` The following policy would evaluate to `true`: ```python import "tfstate" main = rule { tfstate.data.null\_data\_source.foo[0].id is "static" } ``` ### Value: `tainted` \* \*\*Value Type:\*\* Boolean. The `tainted` value within the [resource namespace](#namespace-resources-data-sources) is `true` if the resource is marked as tainted in Terraform state. As an example, given the following resource: ```hcl resource "null\_resource" "foo" { triggers = { foo = "bar" } } ``` The following policy would evaluate to `true`, if the resource was marked as tainted in the state: ```python import "tfstate" main = rule { tfstate.resources.null\_resource.foo[0].tainted } ``` ## Namespace: Outputs The \*\*output namespace\*\* represents all of the outputs present within a [module](#namespace-module). Outputs are present in a state if they were saved during a previous apply, or if they were updated with known values during the pre-plan refresh. \*\*With Terraform 0.11 or earlier\*\* this can be used to fetch both the outputs of the root module, and the outputs of any module in the state below the root. This makes it possible to see outputs that have not been threaded to the root module. \*\*With Terraform 0.12 or later\*\* outputs are available in the top-level (root module) namespace only and not accessible within submodules. This namespace is indexed by output name. ### Value: `sensitive` \* \*\*Value Type:\*\* Boolean. The `sensitive` value within the [output namespace](#namespace-outputs) is `true` when the output has been [marked as sensitive][ref-tf-sensitive-outputs]. [ref-tf-sensitive-outputs]: /terraform/language/values/outputs#sensitive-suppressing-values-in-cli-output As an example, given the following output: ```hcl output "foo" { sensitive = true value = "bar" } ``` The following policy would evaluate to `true`: ```python import "tfstate" main = rule { tfstate.outputs.foo.sensitive } ``` ### Value: `type` \* \*\*Value Type:\*\* String. The `type` value within the [output namespace](#namespace-outputs) gives the output's type. This will be one of `string`, `list`, or `map`. These are currently the only types available for outputs in Terraform. As an example, given the following output: ```hcl output "string" { value = "foo" } output "list" { value = [ "foo", "bar", ] } output "map" { value = { foo = "bar" } } ``` The following policy would evaluate to `true`: ```python import "tfstate" type\_string = rule { tfstate.outputs.string.type is "string" } type\_list = rule { tfstate.outputs.list.type is "list" } type\_map = rule { tfstate.outputs.map.type is "map" } main = rule { type\_string and type\_list and type\_map } ``` ### Value: `value` \* \*\*Value Type:\*\* String, list, or map. The `value` value within the [output namespace](#namespace-outputs) is the value of the output in question. Note that the only valid primitive output type in Terraform is currently a string, which means that any int, float, or boolean value will need to be converted before it can be used in comparison. This does not apply to primitives within maps and lists, which will be their | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfstate.mdx | main | terraform | [
-0.08534706383943558,
0.05107903108000755,
0.0020595965906977654,
0.03421308472752571,
0.0217521283775568,
-0.030452268198132515,
0.11742690205574036,
-0.04496360942721367,
0.007106519304215908,
0.005658650770783424,
-0.015850631520152092,
-0.0908735990524292,
0.08137353509664536,
0.014739... | 0.035953 |
question. Note that the only valid primitive output type in Terraform is currently a string, which means that any int, float, or boolean value will need to be converted before it can be used in comparison. This does not apply to primitives within maps and lists, which will be their original types. As an example, given the following output blocks: ```hcl output "foo" { value = "bar" } output "number" { value = "42" } output "map" { value = { foo = "bar" number = 42 } } ``` The following policy would evaluate to `true`: ```python import "tfstate" value\_foo = rule { tfstate.outputs.foo.value is "bar" } value\_number = rule { int(tfstate.outputs.number.value) is 42 } value\_map\_string = rule { tfstate.outputs.map.value["foo"] is "bar" } value\_map\_int = rule { tfstate.outputs.map.value["number"] is 42 } main = rule { value\_foo and value\_number and value\_map\_string and value\_map\_int } ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/import-reference/tfstate.mdx | main | terraform | [
0.030025547370314598,
0.09884725511074066,
0.05282570794224739,
-0.013828014954924583,
0.012539158575236797,
-0.012011914514005184,
0.03809187561273575,
-0.04913131892681122,
-0.04073571786284447,
0.040057867765426636,
-0.0525004044175148,
-0.07284688949584961,
0.03933482617139816,
0.03683... | 0.001795 |
# Define Sentinel policies in HCP Terraform This topic describes how to create and manage custom policies using Sentinel policy language. For instructions about how to use pre-written Sentinel policies from the registry, refer to [Run pre-written Sentinel policies](/terraform/cloud-docs/policy-enforcement/prewritten-sentinel). ## Overview To define a policy, create a file and declare an `import` function to include reusable libraries, external data, and other functions. Sentinel policy language includes several types of elements you can import using the `import` function. Declare and configure additional Sentinel policy language elements. The details depend on which elements you want to use in your policy. Refer to the [Sentinel documentation](/sentinel/docs) for additional information. @include 'tfc-package-callouts/policies.mdx' ## Declare an `import` function A policy can include imports that enable a policy to access reusable libraries, external data, and functions. Refer to [imports](/sentinel/docs/concepts/imports) in the Sentinel documentation for more details. HCP Terraform provides four imports to define policy rules for the plan, configuration, state, and run associated with a policy check. - [tfplan](/terraform/cloud-docs/policy-enforcement/import-reference/tfplan-v2) - Access a Terraform plan, which is the file created as a result of the [`terraform plan` command](/terraform/cli/commands/plan). The plan represents the changes that Terraform must make to reach the desired infrastructure state described in the configuration. - [tfconfig](/terraform/cloud-docs/policy-enforcement/import-reference/tfconfig-v2) - Access a Terraform configuration. The configuration is the set of `.tf` files that describe the desired infrastructure state. - [tfstate](/terraform/cloud-docs/policy-enforcement/import-reference/tfstate-v2) - Access the Terraform [state](/terraform/language/state). Terraform uses state to map real-world resources to your configuration. - [tfrun](/terraform/cloud-docs/policy-enforcement/import-reference/tfrun) - Access data associated with a [run in HCP Terraform](/terraform/cloud-docs/workspaces/run/remote-operations). For example, you could retrieve the run's workspace. You can create mocks of these imports to use with the the [Sentinel CLI](/sentinel/docs/commands) mocking and testing features. Refer to [Mocking Terraform Sentinel Data](/terraform/cloud-docs/policy-enforcement/test-sentinel) for more details. HCP Terraform does not support custom imports. ## Declare additional elements The following functions and idioms will be useful as you start writing Sentinel policies for Terraform. ### Iterate over modules and find resources The most basic Sentinel task for Terraform is to enforce a rule on all resources of a given type. Before you can do that, you need to get a collection of all the relevant resources from all modules. The easiest way to do that is to copy and use a function like the following into your policies. The following example uses the `tfplan` import. Refer to our [guides for other examples](https://github.com/hashicorp/terraform-guides/tree/master/governance/second-generation/common-functions) of functions that iterate over the `tfconfig` and `tfstate` imports. ```python import "tfplan" import "strings" # Find all resources of specific type from all modules using the tfplan import find\_resources\_from\_plan = func(type) { resources = {} for tfplan.module\_paths as path { for tfplan.module(path).resources[type] else {} as name, instances { for instances as index, r { # Get the address of the resource instance if length(path) == 0 { # root module address = type + "." + name + "[" + string(index) + "]" } else { # non-root module address = "module." + strings.join(path, ".module.") + "." + type + "." + name + "[" + string(index) + "]" } # Add the instance to resources, setting the key to the address resources[address] = r } } } return resources } ``` Call the function to get all resources of a desired type by passing the type as a string in quotation marks: ```python aws\_instances = find\_resources\_from\_plan("aws\_instance") ``` This example function does several useful things while finding resources: - It checks every module (including the root module) for resources of the specified type by iterating over the `module\_paths` namespace. The top-level `resources` namespace is more convenient, but it only reveals resources from the root module. - It iterates over | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/define-policies/custom-sentinel.mdx | main | terraform | [
-0.01175743993371725,
-0.0018396046943962574,
0.009777112863957882,
-0.02918793447315693,
0.019625086337327957,
0.02346244640648365,
0.03257221728563309,
-0.013192393817007542,
-0.03144446015357971,
0.06781642884016037,
-0.03454133868217468,
-0.05202079564332962,
0.042177725583314896,
-0.0... | 0.094111 |
example function does several useful things while finding resources: - It checks every module (including the root module) for resources of the specified type by iterating over the `module\_paths` namespace. The top-level `resources` namespace is more convenient, but it only reveals resources from the root module. - It iterates over the named resources and [resource instances](/terraform/language/expressions/references#resources) found in each module, starting with `tfplan.module(path).resources[type]` which is a series of nested maps keyed by resource names and instance counts. - It uses the Sentinel [`else` operator](/sentinel/docs/language/spec#else-operator) to recover from `undefined` values which would occur for modules that don't have any resources of the specified type. - It builds a flat `resources` map of all resource instances of the specified type. Using a flat map simplifies the code used by Sentinel policies to evaluate rules. - It computes an `address` variable for each resource instance and uses this as the key in the `resources` map. This allows writers of Sentinel policies to print the full [address](/terraform/cli/state/resource-addressing) of each resource instance that violate a policy, using the same address format used in plan and apply logs. Doing this tells users who see violation messages exactly which resources they need to modify in their Terraform code to comply with the Sentinel policies. - It sets the value of the `resources` map to the data associated with the resource instance (`r`). This is the data that Sentinel policies apply rules against. ### Validate resource attributes Once you have a collection of resources instances of a desired type indexed by their addresses, you usually want to validate that one or more resource attributes meets some conditions by iterating over the resource instances. While you could use Sentinel's [`all` and `any` expressions](/sentinel/docs/language/boolexpr#any-all-expressions) directly inside Sentinel rules, your rules would only report the first violation because Sentinel uses short-circuit logic. It is therefore usually preferred to use a [`for` loop](/sentinel/docs/language/loops) outside of your rules so that you can report all violations that occur. You can do this inside functions or directly in the policy itself. Here is a function that calls the `find\_resources\_from\_plan` function and validates that the instance types of all EC2 instances being provisioned are in a given list: ```python # Validate that all EC2 instances have instance\_type in the allowed\_types list validate\_ec2\_instance\_types = func(allowed\_types) { validated = true aws\_instances = find\_resources\_from\_plan("aws\_instance") for aws\_instances as address, r { # Determine if the attribute is computed if r.diff["instance\_type"].computed else false is true { print("EC2 instance", address, "has attribute, instance\_type, that is computed.") } else { # Validate that each instance has allowed value if (r.applied.instance\_type else "") not in allowed\_types { print("EC2 instance", address, "has instance\_type", r.applied.instance\_type, "that is not in the allowed list:", allowed\_types) validated = false } } } return validated } ``` The boolean variable `validated` is initially set to `true`, but it is set to `false` if any resource instance violates the condition requiring that the `instance\_type` attribute be in the `allowed\_types` list. Since the function returns `true` or `false`, it can be called inside Sentinel rules. Note that this function prints a warning message for \*\*every\*\* resource instance that violates the condition. This allows writers of Terraform code to fix all violations after just one policy check. It also prints warnings when the attribute being evaluated is [computed](/terraform/cloud-docs/policy-enforcement/import-reference/tfplan-v2#value-computed) and does not evaluate the condition in this case since the applied value will not be known. While this function allows a rule to validate an attribute against a list, some rules will only need to validate an attribute against a single value; in those cases, you could either use a list with a single | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/define-policies/custom-sentinel.mdx | main | terraform | [
-0.038305237889289856,
0.009637638926506042,
0.017240585759282112,
0.061060961335897446,
0.10568807274103165,
-0.06434077769517899,
0.032690323889255524,
-0.04165464639663696,
0.03105958364903927,
0.017063291743397713,
-0.025554321706295013,
-0.030995098873972893,
0.007536532357335091,
0.0... | 0.198271 |
condition in this case since the applied value will not be known. While this function allows a rule to validate an attribute against a list, some rules will only need to validate an attribute against a single value; in those cases, you could either use a list with a single value or embed that value inside the function itself, drop the `allowed\_types` parameter from the function definition, and use the `is` operator instead of the `in` operator to compare the resource attribute against the embedded value. ### Write Rules Having used the standardized `find\_resources\_from\_plan` function and having written your own function to validate that resources instances of a specific type satisfy some condition, you can define a list with allowed values and write a rule that evaluates the value returned by your validation function. ```python # Allowed Types allowed\_types = [ "t2.small", "t2.medium", "t2.large", ] # Main rule main = rule { validate\_ec2\_instance\_types(allowed\_types) } ``` ### Validate multiple conditions in a single policy If you want a policy to validate multiple conditions against resources of a specific type, you could define a separate validation function for each condition or use a single function to evaluate all the conditions. In the latter case, you would make this function return a list of boolean values, using one for each condition. You can then use multiple Sentinel rules that evaluate those boolean values or evaluate all of them in your `main` rule. Here is a partial example: ```python # Function to validate that S3 buckets have private ACL and use KMS encryption validate\_private\_acl\_and\_kms\_encryption = func() { result = { "private": true, "encrypted\_by\_kms": true, } s3\_buckets = find\_resources\_from\_plan("aws\_s3\_bucket") # Iterate over resource instances and check that S3 buckets # have private ACL and are encrypted by a KMS key # If an S3 bucket is not private, set result["private"] to false # If an S3 bucket is not encrypted, set result["encrypted\_by\_kms"] to false for s3\_buckets as joined\_path, resource\_map { #... } return result } # Call the validation function validations = validate\_private\_acl\_and\_kms\_encryption() # ACL rule is\_private = rule { validations["private"] } # KMS Encryption Rule is\_encrypted\_by\_kms = rule { validations["encrypted\_by\_kms"] } # Main rule main = rule { is\_private and is\_encrypted\_by\_kms } ``` You can write similar functions and policies to restrict Terraform configurations using the `tfconfig` import and to restrict Terraform state using the `tfstate` import. ## Next steps 1. Group your policies into sets and apply them to your workspaces. Refer to [Create policy sets](/terraform/cloud-docs/policy-enforcement/manage-policy-sets#create-policy-sets) for additional information. 1. View results and address Terraform runs that do not comply with your policies. Refer to [View results](/terraform/cloud-docs/policy-enforcement/view-results) for additional information. 1. You can also view Sentinel policy results in JSON format. Refer to [View Sentinel JSON results](/terraform/cloud-docs/policy-enforcement/view-results/json) for additional information. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/define-policies/custom-sentinel.mdx | main | terraform | [
-0.01951713114976883,
0.07363714277744293,
0.03276318311691284,
0.0291381124407053,
0.08129415661096573,
-0.04872016981244087,
0.04684846103191376,
0.007942628115415573,
-0.07465439289808273,
-0.05401398614048958,
-0.038367584347724915,
-0.061663128435611725,
0.05526767671108246,
0.0792669... | 0.017452 |
# Define policies overview This topic provides overview information about how to define policies as code. Policies are rules for enforcing how Terraform provisions infrastructure as code for your workspaces and projects. ## Workflows You can use two policy-as-code frameworks to define fine-grained, logic-based policies: Sentinel and Open Policy Agent (OPA). Depending on the settings, policies can act as advisory warnings or firm requirements that prevent Terraform from provisioning infrastructure. - \*\*Sentinel:\*\* You define policies with the [Sentinel policy language](/sentinel/docs/concepts/language) and use imports to parse the Terraform plan, state, and configuration. Refer to [Define custom Sentinel policies](/terraform/cloud-docs/policy-enforcement/define-policies/custom-sentinel) for details. - \*\*OPA:\*\* You define policies with the [Rego policy language](https://www.openpolicyagent.org/docs/latest/policy-language/). Refer to [Defining OPA Policies](/terraform/cloud-docs/policy-enforcement/define-policies/opa) for details. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/define-policies/index.mdx | main | terraform | [
-0.03723403438925743,
0.01749821938574314,
0.026996079832315445,
-0.0023833352606743574,
0.019651029258966446,
-0.05538618192076683,
-0.00474339397624135,
-0.04923514276742935,
-0.014987451955676079,
0.10599169135093689,
-0.049891382455825806,
-0.0352533720433712,
0.012404512614011765,
0.0... | 0.103447 |
# Define Open Policy Agent policies for HCP Terraform This topic describes how to create and manage custom policies using the open policy agent (OPA) framework. Refer to the following topics for instructions on using HashiCorp Sentinel policies: - [Define custom Sentinel policies](/terraform/cloud-docs/policy-enforcement/define-policies/custom-sentinel) - [Copy pre-written Sentinel policies](/terraform/cloud-docs/policy-enforcement/prewritten-sentinel) @include 'tfc-package-callouts/policies.mdx' ## Overview > \*\*Hands-on:\*\* Try the [Detect Infrastructure Drift and Enforce OPA Policies](/terraform/tutorials/cloud/drift-and-policy) tutorial. You can write OPA policies using the Rego policy language, which is the native query language for the OPA framework. Refer to the following topics in the [OPA documentation](https://www.openpolicyagent.org/docs/latest/policy-language/) for additional information: - [How Do I Write Rego Policies?](https://www.openpolicyagent.org/docs/v0.13.5/how-do-i-write-policies/) - [Rego Policy Playground](https://play.openpolicyagent.org/) ## OPA query You must write a query to identify a specific policy rule within your Rego code. The query may evaluate code from multiple Rego files. The result of each query must return an array, which HCP Terraform uses to determine whether the policy has passed or failed. If the array is empty, HCP Terraform reports that the policy has passed. The query is typically a combination of the policy package name and rule name, such as `data.terraform.deny`. ## OPA input HCP Terraform combines the output from the Terraform run and plan into a single JSON file and passes that file to OPA as input. Refer to the [OPA Overview documentation](https://www.openpolicyagent.org/docs/latest/#the-input-document) for more details about how OPA uses JSON input data. The run data contains information like workspace details and the organization name. To access the properties from the Terraform plan data in your policies, use `input.plan`. To access properties from the Terraform run, use `input.run`. The following example shows sample OPA input data. ```json { "plan": { "format\_version": "1.1", "output\_changes": { }, "planned\_values": { }, "resource\_changes": [ ], "terraform\_version": "1.2.7" }, "run": { "organization": { "name": "hashicorp" }, "workspace": { } } } ``` Use the [Retrieve JSON Execution Plan endpoint](/terraform/cloud-docs/api-docs/plans#retrieve-the-json-execution-plan) to retrieve Terraform plan output data for testing. Refer to [Terraform Run Data](#terraform-run-data) for the properties included in Terraform run output data. ## Example Policies The following example policy parses a Terraform plan and checks whether it includes security group updates that allow ingress traffic from all CIDRs (`0.0.0.0/0`). The OPA query for this example policy is `data.terraform.policies.public\_ingress.deny`. ```rego package terraform.policies.public\_ingress import input.plan as plan deny[msg] { r := plan.resource\_changes[\_] r.type == "aws\_security\_group" r.change.after.ingress[\_].cidr\_blocks[\_] == "0.0.0.0/0" msg := sprintf("%v has 0.0.0.0/0 as allowed ingress", [r.address]) } ``` The following example policy ensures that databases are no larger than 128 GB. The OPA query for this policy is `data.terraform.policies.fws.database.fws\_db\_001.rule`. ```rego package terraform.policies.fws.database.fws\_db\_001 import future.keywords.in import input.plan as tfplan actions := [ ["no-op"], ["create"], ["update"], ] db\_size := 128 resources := [resource\_changes | resource\_changes := tfplan.resource\_changes[\_] resource\_changes.type == "fakewebservices\_database" resource\_changes.mode == "managed" resource\_changes.change.actions in actions ] violations := [resource | resource := resources[\_] not resource.change.after.size == db\_size ] violators[address] { address := violations[\_].address } rule[msg] { count(violations) != 0 msg := sprintf( "%d %q severity resource violation(s) have been detected.", [count(violations), rego.metadata.rule().custom.severity] ) } ``` ## Test policies You can write tests for your policies by [mocking](https://www.openpolicyagent.org/docs/latest/policy-testing/#data-and-function-mocking) the input data the policies use during Terraform runs. The following example policy called `block\_auto\_apply\_runs` checks whether or not an HCP Terraform workspace has been configured to automatically apply a successful Terraform plan. ```rego package terraform.tfc.block\_auto\_apply\_runs import input.run as run deny[msg] { run.workspace.auto\_apply != false msg := sprintf( "HCP Terraform workspace %s has been configured to automatically provision Terraform infrastructure. Change the workspace Apply Method settings to 'Manual Apply'", [run.workspace.name], ) } ``` The following test validates `block\_auto\_apply\_runs`. The test is written in rego and uses the OPA [test format](https://www.openpolicyagent.org/docs/latest/policy-testing/#test-format) to check that the workspace | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/define-policies/opa.mdx | main | terraform | [
-0.021769443526864052,
0.038208574056625366,
0.05248064547777176,
-0.03711549565196037,
-0.007468828000128269,
-0.05995792895555496,
0.023004913702607155,
-0.011045261286199093,
-0.03226390853524208,
0.09780768305063248,
-0.01487121544778347,
-0.05648770555853844,
0.036523908376693726,
-0.... | 0.109724 |
msg := sprintf( "HCP Terraform workspace %s has been configured to automatically provision Terraform infrastructure. Change the workspace Apply Method settings to 'Manual Apply'", [run.workspace.name], ) } ``` The following test validates `block\_auto\_apply\_runs`. The test is written in rego and uses the OPA [test format](https://www.openpolicyagent.org/docs/latest/policy-testing/#test-format) to check that the workspace [apply method](/terraform/cloud-docs/workspaces/settings#apply-method) is not configured to auto apply. You can run this test with the `opa test` CLI command. Refer to [Policy Testing](https://www.openpolicyagent.org/docs/latest/policy-testing/) in the OPA documentation for more details. ```rego package terraform.tfc.block\_auto\_apply\_runs import future.keywords test\_run\_workspace\_auto\_apply if { deny with input as {"run": {"workspace": {"auto\_apply": true}}} } ``` ## Terraform run data Each [Terraform run](/terraform/docs/glossary#run) outputs data describing the run settings and the associated workspace. ### Schema The following code shows the schema for Terraform run data. ``` run βββ id (string) βββ created\_at (string) βββ created\_by (string) βββ message (string) βββ commit\_sha (string) βββ is\_destroy (boolean) βββ refresh (boolean) βββ refresh\_only (boolean) βββ replace\_addrs (array of strings) βββ speculative (boolean) βββ target\_addrs (array of strings) βββ project β βββ id (string) β βββ name (string) βββ variables (map of keys) βββ organization β βββ name (string) βββ workspace βββ id (string) βββ name (string) βββ created\_at (string) βββ description (string) βββ execution\_mode (string) βββ auto\_apply (bool) βββ tags (array of strings) βββ working\_directory (string) βββ vcs\_repo (map of keys) ``` ### Properties The following sections contain details about each property in Terraform run data. #### Run namespace The following table contains the attributes for the `run` namespace. | Properties Name | Type | Description | |---------| ----------| ----------| | `id` | String | The ID associated with the current Terraform run | | `created\_at` | String | The time Terraform created the run. The timestamp follows the [standard timestamp format in RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339). | | `created\_by` | String | A string that specifies the user name of the HCP Terraform user for the specific run.| | `message` | String | The message associated with the Terraform run. The default value is "Queued manually via the Terraform Enterprise API". | | `commit\_sha` | String | The checksum hash (SHA) that identifies the commit | | `is\_destroy` | Boolean | Whether the plan is a destroy plan that destroys all provisioned resources | | `refresh` | Boolean | Whether the state refreshed prior to the plan | | `refresh\_only` | Boolean | Whether the plan is in refresh-only mode. In refresh-only mode, Terraform ignores configuration changes and updates state with any changes made outside of Terraform. | | `replace\_addrs` | An array of strings representing [resource addresses](/terraform/cli/state/resource-addressing) | The targets specified using the [`-replace`](/terraform/cli/commands/plan#replace-address) flag in the CLI or the `replace-addrs` property in the API. Undefined if there are no specified resource targets. | | `speculative` | Boolean | Whether the plan associated with the run is a [speculative plan](/terraform/cloud-docs/workspaces/run/remote-operations#speculative-plans) only | | `target\_addrs` | An array of strings representing [resource addresses](/terraform/cli/state/resource-addressing). | The targets specified using the [`-target`](/terraform/cli/commands/plan#resource-targeting) flag in the CLI or the `target-addrs` property in the API. Undefined if there are no specified resource targets. | | `variables` | A string-keyed map of values. | Provides the variables configured within the run. Each variable `name` maps to two properties: `category` and `sensitive`. The `category` property is a string indicating the variable type, either "input" or "environment". The `sensitive` property is a boolean, indicating whether the variable is a [sensitive value](/terraform/cloud-docs/variables/managing-variables#sensitive-values). | #### Project Namespace The following table contains the properties for the `project` namespace. | Property Name | Type | Description | |---------- | ------------ | -----------| | `id` | String | The ID associated with the Terraform | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/define-policies/opa.mdx | main | terraform | [
-0.0314369797706604,
0.008281601592898369,
0.019204355776309967,
-0.002223346149548888,
0.0042644161731004715,
-0.06992821395397186,
-0.03548358380794525,
-0.018318675458431244,
-0.01431233435869217,
0.09488648921251297,
0.004992095287889242,
-0.09132932871580124,
0.006792341358959675,
0.0... | 0.020279 |
property is a boolean, indicating whether the variable is a [sensitive value](/terraform/cloud-docs/variables/managing-variables#sensitive-values). | #### Project Namespace The following table contains the properties for the `project` namespace. | Property Name | Type | Description | |---------- | ------------ | -----------| | `id` | String | The ID associated with the Terraform project | | `name` | String | The name of the project, which can only include letters, numbers, spaces, `-`, and `\_`. | #### Organization namespace The `organization` namespace has one property called `name`. The `name` property is a string that specifies the name of the HCP Terraform organization for the run. #### Workspace namespace The following table contains the properties for the `workspace` namespace. | Property Name | Type | Description | |---------- | ------------ | -----------| | `id` | String | The ID associated with the Terraform workspace | | `name` | String | The name of the workspace, which can only include letters, numbers, `-`, and `\_` | | `created\_at` | String | The time of the workspace's creation. The timestamp follows the [standard timestamp format in RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339). | | `description` | String | The description for the workspace. This value can be `null`. | | `auto\_apply` | Boolean | The workspace's [auto-apply](/terraform/cloud-docs/workspaces/settings#apply-method) setting | | `tags` | Array of strings | The list of tag names for the workspace | | `working\_directory` | String | The configured [Terraform working directory](/terraform/cloud-docs/workspaces/settings#terraform-working-directory) of the workspace. This value can be `null`. | | `execution\_mode` | String | The configured Terraform execution mode of the workspace. The default value is `remote`. | | `vcs\_repo` | A string-keyed map to objects | Data associated with a VCS repository connected to the workspace. The map contains `identifier` (string), ` display\_identifier` (string), `branch` (string), and `ingress\_submodules` (boolean). Refer to the HCP Terraform [Workspaces API documentation](/terraform/cloud-docs/api-docs/workspaces) for details about each property. This value can be `null`. | ## Next steps - Group your policies into sets and apply them to your workspaces. Refer to [Create policy sets](/terraform/cloud-docs/policy-enforcement/manage-policy-sets#create-policy-sets) for additional information. - View results and address Terraform runs that do not comply with your policies. Refer to [View results](/terraform/cloud-docs/policy-enforcement/view-results) for additional information. - You can also view Sentinel policy results in JSON format. Refer to [View Sentinel JSON results](/terraform/cloud-docs/policy-enforcement/view-results/json) for additional information. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/define-policies/opa.mdx | main | terraform | [
-0.0031168016139417887,
0.02705984376370907,
-0.005960042588412762,
0.05822720006108284,
-0.06420902907848358,
-0.007881661877036095,
0.05896187201142311,
-0.07057633250951767,
0.011496873572468758,
0.047144487500190735,
-0.01993955858051777,
-0.13719874620437622,
0.09478937834501266,
-0.0... | 0.042119 |
[private]: /terraform/cloud-docs/registry [speculative plan]: /terraform/cloud-docs/workspaces/run/remote-operations#speculative-plans [tfe-provider]: https://registry.terraform.io/providers/hashicorp/tfe/latest/docs # The CLI-driven remote run workflow > \*\*Hands-on:\*\* Try the [Log in to HCP Terraform from the CLI](/terraform/tutorials/0-13/cloud-login) tutorial. HCP Terraform has three workflows for managing Terraform runs. - The [UI/VCS-driven run workflow](/terraform/cloud-docs/workspaces/run/ui), which is the primary mode of operation. - The [API-driven run workflow](/terraform/cloud-docs/workspaces/run/api), which is more flexible but requires you to create some tooling. - The CLI-driven run workflow described below, which uses Terraform's standard CLI tools to execute runs in HCP Terraform. ## Summary The [CLI integration](/terraform/cli/cloud) brings HCP Terraform's collaboration features into the familiar Terraform CLI workflow. It offers the best of both worlds to developers who are already comfortable with using the Terraform CLI, and it can work with existing CI/CD pipelines. You can start runs with the standard `terraform plan` and `terraform apply` commands and then watch the progress of the run from your terminal. These runs execute remotely in HCP Terraform, use variables from the appropriate workspace, enforce any applicable [Sentinel or OPA policies](/terraform/cloud-docs/policy-enforcement), and can access HCP Terraform's [private registry][private] and remote state inputs. HCP Terraform offers a few types of CLI-driven runs, to support different stages of your workflow: - `terraform plan` starts a [speculative plan][] in an HCP Terraform workspace, using configuration files from a local directory. You can quickly check the results of edits (including compliance with Sentinel policies) without needing to copy sensitive variables to your local machine. Speculative plans work with all workspaces, and can co-exist with the [VCS-driven workflow](/terraform/cloud-docs/workspaces/run/ui). - `terraform apply` starts a standard plan and apply in an HCP Terraform workspace, using configuration files from a local directory. Remote `terraform apply` is for workspaces without a linked VCS repository. It replaces the VCS-driven workflow with a more traditional CLI workflow. - `terraform plan -out ` and `terraform apply ` perform a two-part [saved plan run](/terraform/cloud-docs/workspaces/run/modes-and-options/#saved-plans) in an HCP Terraform workspace, using configuration files from a local directory. The first command performs and saves the plan, and the second command applies it. You can use `terraform show ` to inspect a saved plan. Like remote `terraform apply`, remote saved plans are for workspaces without a linked VCS repository. Saved plans require at least Terraform CLI v1.6.0. To supplement these remote operations, you can also use the optional [Terraform Enterprise Provider][tfe-provider], which interacts with the HCP Terraform-supported resources. This provider is useful for editing variables and workspace settings through the Terraform CLI. ## Configuration To enable the CLI-driven workflow, you must: 1. Create an account or sign in to [HCP Terraform](https://app.terraform.io/). 1. Run `terraform login` to authenticate with HCP Terraform. Alternatively, you can manually configure credentials in the CLI config file or through environment variables. Refer to [CLI Configuration](/terraform/cli/config/config-file#environment-variable-credentials) for details. If you are in an HCP Europe organization, login to the HCP Europe environment by specifying the hostname: ```shell-session $ terraform login app.terraform.io/eu ``` To learn more about HCP Europe, refer to [Use HCP Terraform in Europe](/terraform/cloud-docs/europe). 1. Add the `cloud` block to your Terraform configuration. You can define its arguments directly in your configuration file or supply them through environment variables, which can be useful for [non-interactive workflows](#non-interactive-workflows). Refer to [Using HCP Terraform](/terraform/cli/cloud) for configuration details. The following example shows how to map CLI workspaces to HCP Terraform workspaces with a specific tag. ``` terraform { cloud { organization = "my-org" workspaces { tags = ["networking"] } } } ``` -> \*\*Note:\*\* The `cloud` block is available in Terraform v1.1 and later. Previous versions can use the [`remote` backend](/terraform/language/settings/backends/remote) to configure the CLI workflow and migrate state. 1. Run `terraform init`. ``` $ terraform init Initializing HCP | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/cli.mdx | main | terraform | [
0.006843152921646833,
0.02304481714963913,
0.00923018530011177,
-0.06099811568856239,
-0.05060475692152977,
-0.05503048375248909,
-0.0684325248003006,
-0.04181019961833954,
0.019152343273162842,
0.053740035742521286,
-0.06047120317816734,
-0.08168606460094452,
0.04192504286766052,
-0.00820... | 0.07865 |
{ organization = "my-org" workspaces { tags = ["networking"] } } } ``` -> \*\*Note:\*\* The `cloud` block is available in Terraform v1.1 and later. Previous versions can use the [`remote` backend](/terraform/language/settings/backends/remote) to configure the CLI workflow and migrate state. 1. Run `terraform init`. ``` $ terraform init Initializing HCP Terraform... Initializing provider plugins... - Reusing previous version of hashicorp/random from the dependency lock file - Using previously-installed hashicorp/random v3.0.1 HCP Terraform has been successfully initialized! You may now begin working with HCP Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. If you ever set or change modules or Terraform Settings, run "terraform init" again to reinitialize your working directory. ``` ### Implicit Workspace Creation If you configure the `cloud` block to use a workspace that doesn't yet exist in your organization, HCP Terraform will create a new workspace with that name when you run `terraform init`. The output of `terraform init` will inform you when this happens. Automatically created workspaces might not be immediately ready to use, so use HCP Terraform's UI to check a workspace's settings and data before performing any runs. In particular, note that: - No Terraform variables or environment variables are created by default, unless your organization has configured one or more [global variable sets](/terraform/cloud-docs/variables#scope). HCP Terraform will use `\*.auto.tfvars` files if they are present, but you will usually still need to set some workspace-specific variables. - The execution mode defaults to "Remote," so that runs occur within HCP Terraform's infrastructure instead of on your workstation. - New workspaces are not automatically connected to a VCS repository and do not have a working directory specified. - A new workspace's Terraform version defaults to the most recent release of Terraform at the time the workspace was created. ### Implicit Project Creation If you configure the [`workspaces` block](/terraform/cli/cloud/settings#workspaces) to use a [project](/terraform/cli/cloud/settings#project) that does not yet exist in your organization, HCP Terraform will attempt to create a new project with that name when you run `terraform init` and notify you in the command output. If you specify both the `project` argument and [`TF\_CLOUD\_PROJECT`](/terraform/cli/cloud/settings#tf\_cloud\_project) environment variable, the `project` argument takes precedence. ## Variables in CLI-Driven Runs Remote runs in HCP Terraform use: - Run-specific variables set through the command line or in your local environment. Terraform can use shell environment variables prefixed with `TF\_VAR\_` as input variables for the run, but you must still set all required environment variables, like provider credentials, inside the workspace. - Workspace-specific Terraform and environment variables set in the workspace. - Any variable sets applied globally, on the project containing the workspace, or on the workspace itself. - Terraform variables from any `\*.auto.tfvars` files included in the configuration. Refer to [Variables](/terraform/cloud-docs/variables) for more details about variable types, variable scopes, variable precedence, and how to set run-specific variables through the command line. ## Remote Working Directories If you manage your Terraform configurations in self-contained repositories, the remote working directory always has the same content as the local working directory. If you use a combined repository and [specify a working directory on workspaces](/terraform/cloud-docs/workspaces/settings#terraform-working-directory), you can run Terraform from either the real working directory or from the root of the combined configuration directory. In both cases, Terraform will upload the entire combined configuration directory. ## Excluding Files from Upload -> \*\*Version note:\*\* `.terraformignore` support was added in Terraform 0.12.11. CLI-driven runs upload an archive of your configuration directory to HCP Terraform. If the directory contains files you want to exclude from upload, you can do so by defining a [`.terraformignore` file in your configuration directory](/terraform/cli/cloud/settings). ## Remote Speculative Plans | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/cli.mdx | main | terraform | [
-0.01631852239370346,
-0.0502442792057991,
0.05815042927861214,
-0.04984477162361145,
0.00338270072825253,
-0.034816160798072815,
-0.04321931675076485,
-0.11634007841348648,
-0.020878806710243225,
0.03724392130970955,
0.011775882914662361,
-0.06664030998945236,
0.016977844759821892,
-0.001... | 0.021909 |
-> \*\*Version note:\*\* `.terraformignore` support was added in Terraform 0.12.11. CLI-driven runs upload an archive of your configuration directory to HCP Terraform. If the directory contains files you want to exclude from upload, you can do so by defining a [`.terraformignore` file in your configuration directory](/terraform/cli/cloud/settings). ## Remote Speculative Plans You can run speculative plans in any workspace where you have [permission to queue plans](/terraform/cloud-docs/users-teams-organizations/permissions). Speculative plans use the configuration code from the local working directory, but will use variable values from the specified workspace. To run a [speculative plan][] on your configuration, use the `terraform plan` command. The plan will run in HCP Terraform, and the logs will stream back to the command line along with a URL to view the plan in the HCP Terraform UI. ``` $ terraform plan Running plan in HCP Terraform. Output will stream here. Pressing Ctrl-C will stop streaming the logs, but will not stop the plan running remotely. Preparing the remote plan... To view this run in a browser, visit: https://app.terraform.io/app/hashicorp-learn/docs-workspace/runs/run-cfh2trDbvMU2Rkf1 Waiting for the plan to start... [...] Plan: 1 to add, 0 to change, 0 to destroy. Changes to Outputs: + pet\_name = (known after apply) ``` [permissions-citation]: #intentionally-unused---keep-for-maintainers ## Remote Applies In workspaces that are not connected to a VCS repository, users with [permission to apply runs](/terraform/cloud-docs/users-teams-organizations/permissions/workspace) can use the CLI to trigger remote applies. Remote applies use the configuration code from the local working directory, but use the variable values from the specified workspace. ~> \*\*Note:\*\* You cannot run remote applies in workspaces that are linked to a VCS repository, since the repository serves as the workspaceβs source of truth. To apply changes in a VCS-linked workspace, merge your changes to the designated branch. When you are ready to apply configuration changes, use the `terraform apply` command. HCP Terraform will plan your changes, and the command line will prompt you for approval before applying them. ``` $ terraform apply Running apply in HCP Terraform. Output will stream here. Pressing Ctrl-C will cancel the remote apply if it's still pending. If the apply started it will stop streaming the logs, but will not stop the apply running remotely. Preparing the remote apply... To view this run in a browser, visit: https://app.terraform.io/app/hashicorp-learn/docs-workspace/runs/run-Rcc12TkNW1PDa7GH Waiting for the plan to start... [...] Plan: 1 to add, 0 to change, 0 to destroy. Changes to Outputs: + pet\_name = (known after apply) Do you want to perform these actions in workspace "docs-workspace"? Terraform will perform the actions described above. Only 'yes' will be accepted to approve. Enter a value: yes [...] Apply complete! Resources: 1 added, 0 changed, 0 destroyed. ``` ### Non-Interactive Workflows > \*\*Hands On:\*\* Try the [Deploy Infrastructure with HCP Terraform and CircleCI](/terraform/tutorials/automation/circle-ci) tutorial. External systems cannot run the traditional apply workflow because Terraform requires console input from the user to approve plans. We recommend using the [API-driven Run Workflow](/terraform/cloud-docs/workspaces/run/api) for non-interactive workflows when possible. If you prefer to use the CLI in a non-interactive environment, we recommend first running a [speculative plan](/terraform/cloud-docs/workspaces/run/remote-operations#speculative-plans) to preview the changes Terraform will make to your infrastructure. Then, use one of the following approaches with the `-auto-approve` flag based on the [execution mode](/terraform/cloud-docs/workspaces/settings#execution-mode) of your workspace. The [`-auto-approve`](/terraform/cli/commands/apply#auto-approve) flag skips prompting you to approve the plan. - \*\*Local Execution:\*\* Save the approved speculative plan and then run `terraform apply -auto-approve` with the saved plan. - \*\*Remote Execution:\*\* HCP Terraform does not support uploading saved plans for remote execution, so we recommend running `terraform apply -auto-approve` immediately after approving the speculative plan to prevent the plan from becoming stale. !> \*\*Warning:\*\* Remote execution with non-interactive workflows requires | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/cli.mdx | main | terraform | [
0.006968043744564056,
0.07622607797384262,
0.0034983642399311066,
-0.0007767052738927305,
0.004085786174982786,
-0.04714100435376167,
-0.0042081004939973354,
-0.07424517720937729,
0.012232520617544651,
0.03224698081612587,
-0.02458438090980053,
-0.05163881182670593,
0.053925395011901855,
-... | 0.00395 |
run `terraform apply -auto-approve` with the saved plan. - \*\*Remote Execution:\*\* HCP Terraform does not support uploading saved plans for remote execution, so we recommend running `terraform apply -auto-approve` immediately after approving the speculative plan to prevent the plan from becoming stale. !> \*\*Warning:\*\* Remote execution with non-interactive workflows requires auto-approved deployments. Minimize the risk of unpredictable infrastructure changes and configuration drift by making sure that no one can change your infrastructure outside of your automated build pipeline. [permissions-citation]: #intentionally-unused---keep-for-maintainers ## Remote Saved Plans -> \*\*Version note:\*\* Saved plans require at least Terraform CLI v1.6.0. In workspaces that support `terraform apply`, you also have the option of performing the plan and apply as separate steps, using the standard variations of the relevant Terraform commands: - `terraform plan -out ` performs and saves a plan. - `terraform apply ` applies a previously saved plan. - `terraform show ` (and `terraform show -json `) inspect a plan you previously saved. Saved plan runs are halfway between [speculative plans](#remote-speculative-plans) and standard [plan and apply runs](#remote-applies). They allow you to: - Perform cheap exploratory plans while retaining the option of applying a specific plan you are satisfied with. - Perform other tasks in your terminal between the plan and apply stages. - Perform the plan and apply operations on separate machines (as is common in continuous integration workflows). Saved plans become \_stale\_ once the state Terraform planned them against is no longer valid (usually due to someone applying a different run). In HCP Terraform, stale saved plan runs are automatically detected and discarded. When examining a remote saved plan, the `terraform show` command (without the `-json` option) informs you if a plan has been discarded or is otherwise unable to be applied. ### File Contents and Permissions You can only apply remote saved plans in the same remote HCP Terraform workspace that performed the plan. Additionally, you can not apply locally executed saved plans in a remote workspace. In order to abide by HCP Terraform's permissions model, remote saved plans do not use the same local file format as locally executed saved plans. Instead, remote saved plans are a thin reference to a remote run, and the Terraform CLI relies on authenticated network requests to inspect and apply remote plans. This helps avoid the accidental exposure of credentials or other sensitive information. The `terraform show -json` command requires [workspace admin permissions](/terraform/cloud-docs/users-teams-organizations/permissions/workspace#workspace-admin) to inspect a remote saved plan; this is because the [machine-readable JSON plan format](/terraform/internals/json-format) contains unredacted sensitive information (alongside redaction hints for use by systems that consume the format). The human-readable version of `terraform show` only requires the read runs permission, because it uses pre-redacted information. [permissions-citation]: #intentionally-unused---keep-for-maintainers ## Policy Enforcement @include 'tfc-package-callouts/policies.mdx' Policies are rules that HCP Terraform enforces on Terraform runs. You can use two policy-as-code frameworks to define fine-grained, logic-based policies: Sentinel and Open Policy Agent (OPA). If the specified workspace uses policies, HCP Terraform runs those policies against all speculative plans and remote applies in that workspace. Failed policies can pause or prevent an apply, depending on the enforcement level. Refer to [Policy Enforcement](/terraform/cloud-docs/policy-enforcement) for details. For Sentinel, the Terraform CLI prints policy results for CLI-driven runs. CLI support for policy results is not available for OPA. The following example shows Sentinel policy output in the terminal. ``` $ terraform apply [...] Plan: 1 to add, 0 to change, 1 to destroy. ------------------------------------------------------------------------ Organization policy check: Sentinel Result: false Sentinel evaluated to false because one or more Sentinel policies evaluated to false. This false was not due to an undefined value or runtime error. 1 policies evaluated. ## Policy | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/cli.mdx | main | terraform | [
-0.025779936462640762,
0.04778052493929863,
0.0850013718008995,
-0.033010903745889664,
0.019601695239543915,
-0.037463508546352386,
-0.07208839058876038,
-0.07131549715995789,
-0.007094904780387878,
0.10232435166835785,
-0.03672488033771515,
-0.06756589561700821,
0.018176674842834473,
-0.0... | -0.011579 |
terraform apply [...] Plan: 1 to add, 0 to change, 1 to destroy. ------------------------------------------------------------------------ Organization policy check: Sentinel Result: false Sentinel evaluated to false because one or more Sentinel policies evaluated to false. This false was not due to an undefined value or runtime error. 1 policies evaluated. ## Policy 1: my-policy.sentinel (soft-mandatory) Result: false FALSE - my-policy.sentinel:1:1 - Rule "main" Do you want to override the soft failed policy check? Only 'override' will be accepted to override. Enter a value: override ``` ## Options for Plans and Applies [Run Modes and Options](/terraform/cloud-docs/workspaces/run/modes-and-options) contains more details about the various options available for plans and applies when you use the CLI-driven workflow. ## Networking/Connection Issues Sometimes during a CLI-driven run, errors relating to network connectivity issues arise. Examples of these kinds of errors include: \* `Client.Timeout exceeded while awaiting headers` \* `context deadline exceeded` \* `TLS handshake timeout` Sometimes there are network problems beyond our control. If you have network errors, verify your network connection is operational. Then, check the following common configuration settings: \* Determine if any firewall software on your system blocks the `terraform` command and explicitly approve it. \* Verify that you have a valid DNS server IP address. \* Remove any expired TLS certificates for your system. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/cli.mdx | main | terraform | [
-0.012100991792976856,
0.008677566424012184,
0.07996132224798203,
0.02041669376194477,
0.05257304757833481,
-0.05682120472192764,
-0.0025855661369860172,
-0.057367030531167984,
-0.003327737096697092,
0.12485141307115555,
-0.013136018067598343,
-0.047316811978816986,
0.004605788737535477,
0... | 0.015363 |
# HCP Terraform's run environment HCP Terraform is designed as an execution platform for Terraform, and most of its features are based around its ability to perform Terraform runs in a fleet of disposable worker VMs. This page describes some features of the run environment for Terraform runs managed by HCP Terraform. ## The Terraform Worker VMs HCP Terraform performs Terraform runs in single-use Linux virtual machines, running on an x86\_64 architecture. The operating system and other software installed on the worker VMs is an internal implementation detail of HCP Terraform. It is not part of a stable public interface, and is subject to change at any time. Before Terraform is executed, the worker VM's shell environment is populated with environment variables from the workspace, the selected version of Terraform is installed, and the run's Terraform configuration version is made available. Changes made to the worker during a run are not persisted to subsequent runs, since the VM is destroyed after the run is completed. Notably, this requires some additional care when installing additional software with a `local-exec` provisioner; see [Installing Additional Tools](/terraform/cloud-docs/workspaces/run/install-software#installing-additional-tools) for more details. > \*\*Hands-on:\*\* Try the [Upgrade Terraform Version in HCP Terraform](/terraform/tutorials/cloud/cloud-versions) tutorial. ## Network Access to VCS and Infrastructure Providers In order to perform Terraform runs, HCP Terraform needs network access to all of the resources Terraform is going to manage. If you are using the cloud version of HCP Terraform, your VCS provider and any private infrastructure providers you manage with Terraform must be internet accessible. If you are on the HCP Terraform \*\*Premium\*\* edition, you can use a self-hosted HCP Terraform agent to connect to private VCS providers. Refer to [Connect to private VCS providers](/terraform/cloud-docs/vcs/private) for more information. Terraform Enterprise instances must have network connectivity to any connected VCS providers or managed infrastructure providers. ## Concurrency and job queuing HCP Terraform uses multiple concurrent worker VMs, which take jobs from a global queue of operations that are ready to execute. This includes both creating new plans and then applying those plans once they've been approved. If the global queue has more jobs than the workers can handle at once, some of them must wait until a worker becomes available. When the queue is backed up, HCP Terraform gives different priorities to different kinds of jobs: - Applying approved plans has the highest priority. - Creation of normal plans has the next-highest priority. - Creation of speculative plans has the lowest priority. HCP Terraform can also delay some jobs to make performance more consistent across organizations. If an organization requests a large number of jobs at once, HCP Terraform queues some of them immediately and delays the rest until some of the initial batch have finished. Doing so allows every organization to continue executing jobs, even during periods of especially heavy load. Your HCP Terraform edition limits the maximum run concurrency for your organization. Refer to [HCP Terraform pricing](https://www.hashicorp.com/products/terraform/pricing?product\_intent=terraform) for details. ## State Access and Authentication [CLI config file]: /terraform/cli/config/config-file [cloud]: /terraform/cli/cloud HCP Terraform stores state for its workspaces. When you trigger runs via the [CLI workflow](/terraform/cloud-docs/workspaces/run/cli), Terraform reads from and writes to HCP Terraform's stored state. HCP Terraform uses [the `cloud` block][cloud] for runs, overriding any existing [backend](/terraform/language/settings/backends/configuration) in the configuration. -> \*\*Note:\*\* The `cloud` block is available in Terraform v1.1 and later. Previous versions can use the [`remote` backend](/terraform/language/settings/backends/remote) to configure the CLI workflow and migrate state. ### Autogenerated API Token Instead of using existing user credentials, HCP Terraform generates a unique per-run API token and provides it to the Terraform worker in the [CLI config file][]. When you run Terraform on | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/run-environment.mdx | main | terraform | [
0.031664200127124786,
0.034255798906087875,
0.03536604717373848,
-0.0189621951431036,
-0.011586309410631657,
-0.04232972115278244,
-0.081743523478508,
-0.06781087070703506,
-0.02210419625043869,
0.037393968552351,
-0.04695853218436241,
-0.0405987873673439,
0.005765355192124844,
-0.04737512... | 0.110405 |
Previous versions can use the [`remote` backend](/terraform/language/settings/backends/remote) to configure the CLI workflow and migrate state. ### Autogenerated API Token Instead of using existing user credentials, HCP Terraform generates a unique per-run API token and provides it to the Terraform worker in the [CLI config file][]. When you run Terraform on the command line against a workspace configured for remote operations, you must have [the `cloud` block][cloud] in your configuration and have a user or team API token with the appropriate permissions specified in your [CLI config file][]. However, the run itself occurs within one of HCP Terraform's worker VMs and uses the per-run token for state access. The per-run token can read and write state data for the workspace associated with the run, can download modules from the [private registry](/terraform/cloud-docs/registry), and may be granted access to read state from other workspaces in the organization. (Refer to [cross-workspace state access](/terraform/cloud-docs/workspaces/state#accessing-state-from-other-workspaces) for more details.) Per-run tokens cannot make any other calls to the HCP Terraform API and are not considered to be user, team, or organization tokens. They become invalid after the run is completed. ### User Token HCP Terraform uses the user token to access a workspace's state when you: - Run Terraform on the command line against a workspace that is \_not\_ configured for remote operations. The user must have permission to read and write state versions for the workspace. - Run Terraform's state manipulation commands against an HCP Terraform workspace. The user must have permission to read and write state versions for the workspace. Refer to [Permissions](/terraform/cloud-docs/users-teams-organizations/permissions/workspace) for more details about workspace permissions. ### Provider Authentication Runs in HCP Terraform typically require some form of credentials to authenticate with infrastructure providers. Credentials can be provided statically through Environment or Terraform [variables](/terraform/cloud-docs/variables), or can be generated on a per-run basis through [dynamic credentials](/terraform/cloud-docs/dynamic-provider-credentials) for certain providers. Below are pros and cons to each approach. #### Static Credentials ##### Pros - Simple to setup - Broad support across providers ##### Cons - Requires regular manual rotation for enhanced security posture - Large blast radius if a credential is exposed and needs to be revoked #### Dynamic Credentials ##### Pros - Eliminates the need for manual rotation of credentials on HCP Terraform - HCP Terraform metadata - including the run's project, workspace, and run-phase - is encoded into every token to allow for granular permission scoping on the target cloud platform - Credentials are short-lived, which reduces blast radius of potential credential exposure ##### Cons - More complicated initial setup compared to using static credentials - Not supported for all providers The full list of supported providers and setup instructions can be found in the [dynamic credentials](/terraform/cloud-docs/dynamic-provider-credentials) documentation. [permissions-citation]: #intentionally-unused---keep-for-maintainers ### Environment Variables HCP Terraform automatically injects the following environment variables for each run: | Variable Name | Description | Example | | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------- | | `TFC\_RUN\_ID` | A unique identifier for this run. | `run-CKuwsxMGgMd4W7Ui` | | `TFC\_WORKSPACE\_ID` | The id of the workspace used in this run | `ws-YN6FoUBQciKyfi4b` | | `TFC\_WORKSPACE\_NAME` | The name of the workspace used in this run. | `prod-load-balancers` | | `TFC\_WORKSPACE\_SLUG` | The full slug of the configuration used in this run. This consists of the organization name and workspace name, joined with a slash. | `acme-corp/prod-load-balancers` | | `TFC\_CONFIGURATION\_VERSION\_GIT\_BRANCH` | The name of the branch that the associated Terraform configuration version was ingressed from. | `main` | | `TFC\_CONFIGURATION\_VERSION\_GIT\_COMMIT\_SHA` | The full commit hash of the commit that the associated Terraform configuration version was ingressed from. | `abcd1234...` | | `TFC\_CONFIGURATION\_VERSION\_GIT\_TAG` | The name of the tag that the | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/run-environment.mdx | main | terraform | [
-0.03295611962676048,
-0.02449401281774044,
0.003346903482452035,
-0.05369812995195389,
-0.041745491325855255,
0.005954259540885687,
-0.028064018115401268,
-0.0448574498295784,
0.011891704052686691,
0.02296445518732071,
-0.07249952852725983,
-0.06588618457317352,
0.048081863671541214,
0.02... | 0.059167 |
| The name of the branch that the associated Terraform configuration version was ingressed from. | `main` | | `TFC\_CONFIGURATION\_VERSION\_GIT\_COMMIT\_SHA` | The full commit hash of the commit that the associated Terraform configuration version was ingressed from. | `abcd1234...` | | `TFC\_CONFIGURATION\_VERSION\_GIT\_TAG` | The name of the tag that the associated Terraform configuration version was ingressed from. | `v0.1.0` | | `TFC\_PROJECT\_NAME` | The name of the project used in this run. | `proj-name` | | `TFC\_PROJECT\_ID`. | The id of the project used in this run. | `proj-91XJpbLvbdohC6RD` | They are also available as Terraform input variables by defining a variable with the same name. For example: ```terraform variable "TFC\_RUN\_ID" {} ``` | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/run-environment.mdx | main | terraform | [
0.018017971888184547,
0.03113352134823799,
-0.008480967953801155,
-0.021396655589342117,
0.016563288867473602,
0.007610526867210865,
0.005989175755530596,
-0.013531124219298363,
0.05008010193705559,
0.05697305500507355,
0.010335986502468586,
-0.03712739795446396,
0.04420219734311104,
-0.05... | 0.050098 |
# Run states and stages Each plan and apply run passes through several stages of action: pending, plan, cost estimation, policy check, apply, and completion. HCP Terraform shows a run's progress through each stage as a run state. In the list of workspaces on HCP Terraform's main page, each workspace shows the state of the run it's currently processing. If no run is in progress, HCP Terraform displays the state of the most recently completed run. ## The Pending Stage \_States in this stage:\_ - \*\*Pending:\*\* HCP Terraform hasn't started action on a run yet. HCP Terraform processes each workspace's runs in the order they were queued, and a run remains pending until every run before it has completed. \_Leaving this stage:\_ - If the user discards the run before it starts, the run does not continue (\*\*Discarded\*\* state). - If the run is first in the queue, it proceeds automatically to the plan stage (\*\*Planning\*\* state). ## The Fetching Stage HCP Terraform may need to fetch the configuration from VCS prior to starting the plan. HCP Terraform automatically archives configuration versions created through VCS when all runs are complete and then re-fetches the files for subsequent runs. \_States in this stage:\_ - \*\*Fetching:\*\* If HCP Terraform has not yet fetched the configuration from VCS, the run will go into this state until the configuration is available. \_Leaving this stage:\_ - If HCP Terraform encounters an error when fetching the configuration from VCS, the run does not continue (\*\*Plan Errored\*\* state). - If Terraform successfully fetches the configuration, the run moves to the next stage. ## The Pre-Plan Stage The pre-plan phase only occurs if there are enabled [run tasks](/terraform/cloud-docs/workspaces/settings/run-tasks) in the workspace that are configured to begin before Terraform creates the plan. HCP Terraform sends information about the run to the configured external system and waits for a `passed` or `failed` response to determine whether the run can continue. The information sent to the external system includes the configuration version of the run. All runs can enter this phase, including [speculative plans](/terraform/cloud-docs/workspaces/run/remote-operations#speculative-plans). \_States in this stage:\_ - \*\*Pre-plan running:\*\* HCP Terraform is waiting for a response from the configured external system(s). - External systems must respond initially with a `200 OK` acknowledging the request is in progress. After that, they have 10 minutes to return a status of `passed`, `running`, or `failed`. If the timeout expires, HCP Terraform assumes that the run tasks is in the `failed` status. \_Leaving this stage:\_ - If any mandatory tasks failed, the run skips to completion (\*\*Plan Errored\*\* state). - If any advisory tasks failed, the run proceeds to the \*\*Planning\*\* state, with a visible warning regarding the failed task. - If a single run has a combination of mandatory and advisory tasks, Terraform takes the most restrictive action. For example, the run fails if there are two advisory tasks that succeed and one mandatory task that fails. - If a user canceled the run, the run ends in the \*\*Canceled\*\* state. ## The Plan Stage A run goes through different steps during the plan stage depending on whether or not HCP Terraform needs to fetch the configuration from VCS. HCP Terraform automatically archives configuration versions created through VCS when all runs are complete and then re-fetches the files for subsequent runs. \_States in this stage:\_ - \*\*Planning:\*\* HCP Terraform is currently running `terraform plan`. - \*\*Needs Confirmation:\*\* `terraform plan` has finished. Runs sometimes pause in this state, depending on the workspace and organization settings. \_Leaving this stage:\_ - If the `terraform plan` command failed, the run does not continue (\*\*Plan Errored\*\* state). | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/states.mdx | main | terraform | [
-0.005277056712657213,
0.03621301054954529,
0.06790453940629959,
-0.0027016308158636093,
0.008586659096181393,
-0.016931898891925812,
0.0011096770176663995,
-0.1071915253996849,
0.00726680364459753,
0.04509966820478439,
-0.040115274488925934,
-0.067698173224926,
0.04295223206281662,
-0.052... | 0.073179 |
in this stage:\_ - \*\*Planning:\*\* HCP Terraform is currently running `terraform plan`. - \*\*Needs Confirmation:\*\* `terraform plan` has finished. Runs sometimes pause in this state, depending on the workspace and organization settings. \_Leaving this stage:\_ - If the `terraform plan` command failed, the run does not continue (\*\*Plan Errored\*\* state). - If a user canceled the plan by pressing the "Cancel Run" button, the run does not continue (\*\*Canceled\*\* state). - If the plan succeeded with no changes and neither cost estimation nor Sentinel policy checks will be done, HCP Terraform considers the run complete (\*\*Planned and Finished\*\* state). - If the plan succeeded and requires changes: - If cost estimation is enabled, the run proceeds automatically to the cost estimation stage. - If cost estimation is disabled and [Sentinel policies](/terraform/cloud-docs/policy-enforcement/define-policies/custom-sentinel) are enabled, the run proceeds automatically to the policy check stage. - If there are no Sentinel policies and the plan can be auto-applied, the run proceeds automatically to the apply stage. Plans can be auto-applied if the auto-apply setting is enabled on the workspace and the plan was queued by a new VCS commit or by a user with permission to apply runs. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) - If there are no Sentinel policies and HCP Terraform cannot auto-apply the plan, the run pauses in the \*\*Needs Confirmation\*\* state until a user with permission to apply runs takes action. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) If an authorized user approves the apply, the run proceeds to the apply stage. If an authorized user rejects the apply, the run does not continue (\*\*Discarded\*\* state). [permissions-citation]: #intentionally-unused---keep-for-maintainers Note, if you want to directly integrate third-party tools and services between your plan and apply stages, see [Run Tasks](/terraform/cloud-docs/workspaces/settings/run-tasks). ## The Post-Plan Stage The post-plan phase only occurs if you configure [run tasks](/terraform/cloud-docs/workspaces/settings/run-tasks) on a workspace to begin after Terraform successfully completes a plan operation. All runs can enter this phase, including [speculative plans](/terraform/cloud-docs/workspaces/run/remote-operations#speculative-plans). During this phase, HCP Terraform sends information about the run to the configured external system and waits for a `passed` or `failed` response to determine whether the run can continue. -> \*\*Note:\*\* The information sent to the configured external system includes the [JSON output](/terraform/internals/json-format) of the Terraform plan. \_States in this stage:\_ - \*\*Post-plan running:\*\* HCP Terraform is waiting for a response from the configured external system(s). - External systems must respond initially with a `200 OK` acknowledging the request is in progress. After that, they have 10 minutes to return a status of `passed`, `running`, or `failed`, or the timeout will expire and the task will be assumed to be in the `failed` status. \_Leaving this stage:\_ - If any mandatory tasks failed, the run skips to completion (\*\*Plan Errored\*\* state). - If any advisory tasks failed, the run proceeds to the \*\*Applying\*\* state, with a visible warning regarding the failed task. - If a single run has a combination of mandatory and advisory tasks, Terraform takes the most restrictive action. For example, if there are two advisory tasks that succeed and one mandatory task that failed, the run fails. If one mandatory task succeeds and two advisory tasks fail, the run succeeds with a warning. - If a user canceled the run, the run ends in the \*\*Canceled\*\* state. ## The OPA Policy Check Stage This stage only occurs if you enabled [Open Policy Agent (OPA) policies](/terraform/cloud-docs/policy-enforcement/opa) and runs after a successful `terraform plan` and before Cost Estimation. In this stage, HCP Terraform checks whether the plan adheres to the policies in the OPA policy sets for the workspace. \_States in this stage:\_ - \*\*Policy Check:\*\* HCP Terraform is checking | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/states.mdx | main | terraform | [
-0.0028990551363676786,
0.05298550799489021,
0.06551044434309006,
0.021057171747088432,
0.03366817533969879,
-0.006691907066851854,
-0.007905859500169754,
-0.0759214237332344,
0.016351159662008286,
0.07680163532495499,
-0.025557152926921844,
-0.07131443917751312,
0.035040728747844696,
-0.0... | 0.104861 |
you enabled [Open Policy Agent (OPA) policies](/terraform/cloud-docs/policy-enforcement/opa) and runs after a successful `terraform plan` and before Cost Estimation. In this stage, HCP Terraform checks whether the plan adheres to the policies in the OPA policy sets for the workspace. \_States in this stage:\_ - \*\*Policy Check:\*\* HCP Terraform is checking the plan against the OPA policy sets. - \*\*Policy Override:\*\* The policy check finished, but a mandatory policy failed. The run pauses, and Terraform cannot perform an apply unless a user manually overrides the policy check failure. Refer to [Policy Results](/terraform/cloud-docs/policy-enforcement/view-results) for details. - \*\*Policy Checked:\*\* The policy check succeeded, and Terraform can apply the plan. The run may pause in this state if the workspace is not set up to auto-apply runs. \_Leaving this stage:\_ If any mandatory policies failed, the run pauses in the \*\*Policy Override\*\* state. The run completes one of the following workflows: - The run stops and enters the \*\*Discarded\*\* state when a user with [permission to apply runs](/terraform/cloud-docs/users-teams-organizations/permissions/workspace#manage-policy-overrides) discards the run. - The run proceeds to the \*\*Policy Checked\*\* state when a user with [permission to manage policy overrides](/terraform/cloud-docs/users-teams-organizations/permissions) overrides the failed policy. The \*\*Policy Checked\*\* state means that no mandatory policies failed or that a user performed a manual override. Once the run reaches the \*\*Policy Checked\*\* state, the run completes one of the following workflows: - The run proceeds to the \*\*Apply\*\* stage if Terraform can automatically apply the plan. An auto-apply requires that the \*\*Auto apply\*\* setting is enabled on the workspace. - If Terraform cannot automatically apply the plan, the run pauses in the \*\*Policy Checked\*\* state until a user with permission to apply runs takes action. If the user approves the apply, the run proceeds to the \*\*Apply\*\* stage. If the user rejects the apply, the run stops and enters the \*\*Discarded\*\* state. ## The Cost Estimation Stage This stage only occurs if cost estimation is enabled. After a successful `terraform plan`, HCP Terraform uses plan data to estimate costs for each resource found in the plan. \_States in this stage:\_ - \*\*Cost Estimating:\*\* HCP Terraform is currently estimating the resources in the plan. - \*\*Cost Estimated:\*\* The cost estimate completed. \_Leaving this stage:\_ - If cost estimation succeeded or errors, the run moves to the next stage. - If there are no policy checks or applies, the run does not continue (\*\*Planned and Finished\*\* state). ## The Sentinel Policy Check Stage This stage only occurs if [Sentinel policies](/terraform/cloud-docs/policy-enforcement/define-policies/custom-sentinel) are enabled. After a successful `terraform plan`, HCP Terraform checks whether the plan obeys policy to determine whether it can be applied. \_States in this stage:\_ - \*\*Policy Check:\*\* HCP Terraform is currently checking the plan against the organization's policies. - \*\*Policy Override:\*\* The policy check finished, but a soft-mandatory policy failed, so an apply cannot proceed without approval from a user with permission to manage policy overrides for the organization. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) The run pauses in this state. - \*\*Policy Checked:\*\* The policy check succeeded, and Sentinel will allow an apply to proceed. The run sometimes pauses in this state, depending on workspace settings. [permissions-citation]: #intentionally-unused---keep-for-maintainers \_Leaving this stage:\_ - If any hard-mandatory policies failed, the run does not continue (\*\*Plan Errored\*\* state). - If any soft-mandatory policies failed, the run pauses in the \*\*Policy Override\*\* state. - If a user with permission to manage policy overrides, overrides the failed policy, the run proceeds to the \*\*Policy Checked\*\* state. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) - If a user with permission to apply runs discards the run, the run does not continue (\*\*Discarded\*\* state). ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) - If the run | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/states.mdx | main | terraform | [
0.0022471954580396414,
0.014749038964509964,
0.06111958622932434,
0.024434693157672882,
0.003990514203906059,
-0.06355109810829163,
-0.025387510657310486,
-0.06231851875782013,
0.003778328187763691,
0.09724341332912445,
-0.023449430242180824,
-0.060078538954257965,
0.014544888399541378,
-0... | -0.016178 |
If a user with permission to manage policy overrides, overrides the failed policy, the run proceeds to the \*\*Policy Checked\*\* state. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) - If a user with permission to apply runs discards the run, the run does not continue (\*\*Discarded\*\* state). ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) - If the run reaches the \*\*Policy Checked\*\* state (no mandatory policies failed, or soft-mandatory policies were overridden): - If the plan can be auto-applied, the run proceeds automatically to the apply stage. Plans can be auto-applied if the auto-apply setting is enabled on the workspace and the plan was queued by a new VCS commit or by a user with permission to apply runs. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) - If the plan can't be auto-applied, the run pauses in the \*\*Policy Checked\*\* state until a user with permission to apply runs takes action. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) The run proceeds to the apply stage if they approve the apply, or does not continue (\*\*Discarded\*\* state) if they reject the apply. [permissions-citation]: #intentionally-unused---keep-for-maintainers ## The Pre-Apply Stage The pre-apply phase only occurs if the workspace has [run tasks](/terraform/cloud-docs/workspaces/settings/run-tasks) configured to begin before Terraform creates the apply. HCP Terraform sends information about the run to the configured external system and waits for a `passed` or `failed` response to determine whether the run can continue. The information sent to the external system includes the configuration version of the run. Only confirmed runs can enter this phase. \_States in this stage:\_ - \*\*Pre-apply running:\*\* HCP Terraform is waiting for a response from the configured external system(s). - External systems must respond initially with a `200 OK` acknowledging the request is in progress. After that, they have 10 minutes to return a status of `passed`, `running`, or `failed`. If the timeout expires, HCP Terraform assumes that the run tasks is in the `failed` status. \_Leaving this stage:\_ - If any mandatory tasks failed, the run skips to completion. - If any advisory tasks failed, the run proceeds to the \*\*Applying\*\* state, with a visible warning regarding the failed task. - If a single run has a combination of mandatory and advisory tasks, Terraform takes the most restrictive action. For example, the run fails if there are two advisory tasks that succeed and one mandatory task that fails. - If a user canceled the run, the run ends in the \*\*Canceled\*\* state. ## The Apply Stage \_States in this stage:\_ - \*\*Applying:\*\* HCP Terraform is currently running `terraform apply`. \_Leaving this stage:\_ After applying, the run proceeds automatically to completion. - If the apply succeeded, the run ends in the \*\*Applied\*\* state. - If the apply failed, the run ends in the \*\*Apply Errored\*\* state. - If a user canceled the apply by pressing \*\*Cancel Run\*\*, the run ends in the \*\*Canceled\*\* state. ## The Post-Apply Stage The post-apply phase only occurs if you configure [run tasks](/terraform/cloud-docs/workspaces/settings/run-tasks) on a workspace to begin after Terraform successfully completes an apply operation. During this phase, HCP Terraform sends information about the run to the configured external system and waits for a `passed` or `failed` response. However, unlike other stages in the run task process, a failed outcome does not halt the run since HCP Terraform has already provisioned the infrastructure. \_States in this stage:\_ - \*\*Post-apply running:\*\* HCP Terraform is waiting for a response from the configured external system(s). - External systems must respond initially with a `200 OK` acknowledging the request is in progress. After that, they have 10 minutes to return a status of `passed`, `running`, or `failed`. If the timeout expires, HCP Terraform assumes that the run tasks is in the | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/states.mdx | main | terraform | [
-0.023692462593317032,
0.043159473687410355,
0.06508004665374756,
-0.0024171415716409683,
0.011622722260653973,
-0.053590819239616394,
-0.00006555314030265436,
-0.06579510867595673,
-0.005529513116925955,
0.11480268090963364,
-0.02730793133378029,
0.022880014032125473,
0.00919268187135458,
... | 0.018571 |
from the configured external system(s). - External systems must respond initially with a `200 OK` acknowledging the request is in progress. After that, they have 10 minutes to return a status of `passed`, `running`, or `failed`. If the timeout expires, HCP Terraform assumes that the run tasks is in the `failed` status. \_Leaving this stage:\_ - There are only advisory tasks on this stage. - If any advisory tasks failed, the run proceeds to the \*\*Applied\*\* state, with a visible warning regarding the failed task. - If a user cancels the run, the run ends in the \*\*Canceled\*\* state. ## Completion A run is complete if it finishes applying, if any part of the run fails, if there is nothing to do, or if a user chooses not to continue. Once a run completes, the next run in the queue can enter the plan stage. \_States in this stage:\_ - \*\*Applied:\*\* The run was successfully applied. - \*\*Planned and Finished:\*\* `terraform plan`'s output already matches the current infrastructure state, so `terraform apply` doesn't need to do anything. - \*\*Apply Errored:\*\* The `terraform apply` command failed, possibly due to a missing or misconfigured provider or an illegal operation on a provider. - \*\*Plan Errored:\*\* The `terraform plan` command failed (usually requiring fixes to variables or code), or a hard-mandatory Sentinel policy failed. The run cannot be applied. - \*\*Discarded:\*\* A user chose not to continue this run. - \*\*Canceled:\*\* A user interrupted the `terraform plan` or `terraform apply` command with the "Cancel Run" button. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/states.mdx | main | terraform | [
-0.043538469821214676,
0.05107695981860161,
0.04195595532655716,
0.009078503586351871,
0.0175715833902359,
-0.03781610354781151,
-0.027943605557084084,
-0.0515066497027874,
0.01622762344777584,
0.05275312811136246,
-0.029887663200497627,
-0.059576258063316345,
0.059354763478040695,
-0.0555... | 0.08982 |
# Remote operations > \*\*Hands-on:\*\* Try the [Get Started β HCP Terraform](/terraform/tutorials/cloud-get-started?utm\_source=WEBSITE&utm\_medium=WEB\_IO&utm\_offer=ARTICLE\_PAGE&utm\_content=DOCS) tutorials. HCP Terraform provides a central interface for running Terraform within a large collaborative organization. If you're accustomed to running Terraform from your workstation, the way HCP Terraform manages runs can be unfamiliar. This page describes the basics of how runs work in HCP Terraform. ## Remote Operations HCP Terraform is designed as an execution platform for Terraform, and can perform Terraform runs on its own disposable virtual machines. This provides a consistent and reliable run environment, and enables advanced features like Sentinel policy enforcement, cost estimation, notifications, version control integration, and more. Terraform runs managed by HCP Terraform are called \_remote operations.\_ Remote runs can be initiated by webhooks from your VCS provider, by UI controls within HCP Terraform, by API calls, or by Terraform CLI. When using Terraform CLI to perform remote operations, the progress of the run is streamed to the user's terminal, to provide an experience equivalent to local operations. ### Disabling Remote Operations [execution\_mode]: /terraform/cloud-docs/workspaces/settings#execution-mode Many of HCP Terraform's features rely on remote execution and are not available when using local operations. This includes features like Sentinel policy enforcement, cost estimation, and notifications. You can disable remote operations for any workspace by changing its [Execution Mode][execution\_mode] to \*\*Local\*\*. This causes the workspace to act only as a remote backend for Terraform state, with all execution occurring on your own workstations or continuous integration workers. ### Protecting Private Environments [HCP Terraform agents](/terraform/cloud-docs/agents) are a paid feature that allows HCP Terraform to communicate with isolated, private, or on-premises infrastructure. The agent polls HCP Terraform or Terraform Enterprise for any changes to your configuration and executes the changes locally, so you do not need to allow public ingress traffic to your resources. Agents allow you to control infrastructure in private environments without modifying your network perimeter. HCP Terraform agents also support running custom programs, called \_hooks\_, during strategic points of a Terraform run. For example, you may create a hook to dynamically download software required by the Terraform run or send an HTTP request to a system to kick off an external workflow. ## Runs and Workspaces HCP Terraform always performs Terraform runs in the context of a [workspace](/terraform/cloud-docs/workspaces/run/remote-operations). The workspace serves the same role that a persistent working directory serves when running Terraform locally: it provides the configuration, state, and variables for the run. ### Configuration Versions Each workspace is associated with a particular Terraform configuration, but that configuration is expected to change over time. Thus, HCP Terraform manages configurations as a series of \_configuration versions.\_ Most commonly, a workspace is linked to a VCS repository, and its configuration versions are tied to revisions in the specified VCS branch. In workspaces that aren't linked to a repository, new configuration versions can be uploaded via Terraform CLI or via the API. ### Ordering and Timing Each workspace in HCP Terraform maintains its own queue of runs, and processes those runs in order. Whenever a new run is initiated, it's added to the end of the queue. If there's already a run in progress, the new run won't start until the current one has completely finished β HCP Terraform won't even plan the run yet, because the current run might change what a future run would do. Runs that are waiting for other runs to finish are in a \_pending\_ state, and a workspace might have any number of pending runs. There are two exceptions to the run queue, which can proceed at any time and do not block the progress of other runs: - Plan-only runs. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/remote-operations.mdx | main | terraform | [
0.004209311679005623,
0.005443086847662926,
0.003823960432782769,
-0.01853053830564022,
-0.035567473620176315,
-0.037466343492269516,
-0.0675484836101532,
-0.0348832942545414,
-0.01389964111149311,
0.0644654706120491,
-0.01851613260805607,
-0.052933309227228165,
0.05578926205635071,
-0.066... | 0.105021 |
Runs that are waiting for other runs to finish are in a \_pending\_ state, and a workspace might have any number of pending runs. There are two exceptions to the run queue, which can proceed at any time and do not block the progress of other runs: - Plan-only runs. - The planning stages of [saved plan runs](/terraform/cloud-docs/workspaces/run/modes-and-options/#saved-plans). You can only \_apply\_ a saved plan if no other run is in progress, and applying that plan blocks the run queue as usual. Terraform Enterprise does not yet support this workflow. When you initiate a run, HCP Terraform locks the run to a particular configuration version and set of variable values. If you change variables or commit new code before the run finishes, it will only affect future runs, not runs that are already pending, planning, or awaiting apply. ### Workspace Locks When a workspace is \_locked,\_ HCP Terraform can create new runs (automatically or manually), but those runs do not begin until you unlock the workspace. When a run is in progress, that run locks the workspace, as described above under "Ordering and Timing". There are two kinds of run operation that can ignore workspace locking: - Plan-only runs. - The planning stages of [saved plan runs](/terraform/cloud-docs/workspaces/run/modes-and-options/#saved-plans). You can only \_apply\_ a saved plan if the workspace is unlocked, and applying that plan locks the workspace as usual. Terraform Enterprise does not yet support this workflow. A user or team can also deliberately lock a workspace, to perform maintenance or for any other reason. For more details, see [Locking Workspaces (Preventing Runs)](/terraform/cloud-docs/workspaces/run/manage#locking-workspaces-preventing-runs-). ## Starting Runs HCP Terraform has three main workflows for managing runs, and your chosen workflow determines when and how Terraform runs occur. For detailed information, see: - The [UI/VCS-driven run workflow](/terraform/cloud-docs/workspaces/run/ui), which is the primary mode of operation. - The [API-driven run workflow](/terraform/cloud-docs/workspaces/run/api), which is more flexible but requires you to create some tooling. - The [CLI-driven run workflow](/terraform/cloud-docs/workspaces/run/cli), which uses Terraform's standard CLI tools to execute runs in HCP Terraform. You can use the following methods to initiate HCP Terraform runs: - Click the \*\*+ New run\*\* button on the workspace's page - Implement VCS webhooks - Run the standard `terraform apply` command when the CLI integration is configured - Call [the Runs API](/terraform/cloud-docs/api-docs/run) using any API tool ## Plans and Applies HCP Terraform enforces Terraform's division between \_plan\_ and \_apply\_ operations. It always plans first, then uses that plan's output for the apply. In the default configuration, HCP Terraform waits for user approval before running an apply, but you can configure workspaces to [automatically apply](/terraform/cloud-docs/workspaces/settings#auto-apply-and-manual-apply) successful plans. Some plans can't be auto-applied, like plans queued by [run triggers](/terraform/cloud-docs/workspaces/settings/run-triggers) or by users without permission to apply runs for the workspace. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) [permissions-citation]: #intentionally-unused---keep-for-maintainers If a plan contains no changes, HCP Terraform does not attempt to apply it. Instead, the run ends with a status of "Planned and finished". The [allow empty apply](/terraform/cloud-docs/workspaces/run/modes-and-options#allow-empty-apply) run mode can override this behavior. ### Speculative Plans In addition to normal runs, HCP Terraform can run \_speculative plans\_ to test changes to a configuration during editing and code review. Speculative plans are plan-only runs. They show possible changes, and policies affected by those changes, but cannot apply any changes. Speculative plans can begin without waiting for other runs to finish because they don't affect real infrastructure. HCP Terraform lists past speculative plan runs alongside a workspace's other runs. There are three ways to run speculative plans: - In VCS-backed workspaces, pull requests start speculative plans, and the VCS provider's pull request interface includes a link to the plan. See [UI/VCS | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/remote-operations.mdx | main | terraform | [
-0.005190461408346891,
-0.00916933175176382,
0.04533927142620087,
0.010508207604289055,
-0.015991317108273506,
-0.0035948692820966244,
-0.05732876807451248,
-0.1359037607908249,
0.0647580549120903,
0.0750693827867508,
-0.04202931374311447,
-0.006209094077348709,
-0.009565627202391624,
-0.0... | 0.027864 |
because they don't affect real infrastructure. HCP Terraform lists past speculative plan runs alongside a workspace's other runs. There are three ways to run speculative plans: - In VCS-backed workspaces, pull requests start speculative plans, and the VCS provider's pull request interface includes a link to the plan. See [UI/VCS Runs: Speculative Plans on Pull Requests](/terraform/cloud-docs/workspaces/run/ui#speculative-plans-on-pull-requests) for more details. - With the [CLI integration](/terraform/cli/cloud) configured, running `terraform plan` on the command line starts a speculative plan. The plan output streams to the terminal, and a link to the plan is also included. - The runs API creates speculative plans whenever the specified configuration version is marked as speculative. See [the `configuration-versions` API](/terraform/cloud-docs/api-docs/configuration-versions#create-a-configuration-version) for more information. #### Retry a speculative plan in the UI If a speculative plan fails due to an external factor, you can run it again using the "Retry Run" button on its page: Retrying a plan requires permission to queue plans for that workspace. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) Only failed or canceled plans can be retried. [permissions-citation]: #intentionally-unused---keep-for-maintainers Retrying the run will create a new run with the same configuration version. If it is a VCS-backed workspace, the pull request interface will receive the status of the new run, along with a link to the new run. ### Saved Plans -> \*\*Version note:\*\* Using saved plans from the CLI with HCP Terraform requires at least Terraform CLI v1.6.0. HCP Terraform also supports saved plan runs. If you have configured the [CLI integration](/terraform/cli/cloud) you can use `terraform plan -out ` to perform and save a plan, `terraform apply ` to apply a saved plan, and `terraform show ` to inspect a saved plan before applying it. You can also create saved plan runs via the API by using the `save-plan` option. Saved plan runs affect the run queue differently from normal runs, and can sometimes be automatically discarded. For more details, refer to [Run Modes and Options: Saved Plans](/terraform/cloud-docs/workspaces/run/modes-and-options#saved-plans). ## Planning Modes and Options In addition to the normal run workflows described above, HCP Terraform supports destroy runs, refresh-only runs, and several planning options that can modify the behavior of a run. For more details, see [Run Modes and Options](/terraform/cloud-docs/workspaces/run/modes-and-options). ## Run States HCP Terraform shows the progress of each run as it passes through each run state (pending, plan, policy check, apply, and completion). In some states, the run might require confirmation before continuing or ending; see [Managing Runs: Interacting with Runs](/terraform/cloud-docs/workspaces/run/manage#interacting-with-runs) for more information. In the list of workspaces on HCP Terraform's main page, each workspace shows the state of the run it's currently processing. (Or, if no run is in progress, the state of the most recent completed run.) For full details about the stages of a run, see [Run States and Stages][]. [Run States and Stages]: /terraform/cloud-docs/workspaces/run/states ## Import We recommend using [`import` blocks](/terraform/language/import), introduced in Terraform 1.5, to import resources in HCP Terraform. HCP Terraform does not support remote execution for the `terraform import` command. For this command the workspace acts only as a remote backend for Terraform state, with all execution occurring on your own workstations or continuous integration workers. Since `terraform import` runs locally, environment variables defined in the workspace are not available. Any environment variables required by the provider you're importing from must be defined within your local execution scope. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/remote-operations.mdx | main | terraform | [
-0.005117230117321014,
-0.002858510008081794,
0.07849868386983871,
0.001145809656009078,
0.04945074021816254,
-0.06206030398607254,
-0.05059477686882019,
-0.058084167540073395,
0.09613615274429321,
0.03886224702000618,
-0.06251341104507446,
-0.026260647922754288,
0.006046098656952381,
-0.0... | -0.000706 |
# Install software in the run environment Terraform relies on provider plugins to manage resources. In most cases, Terraform can automatically download the required plugins, but there are cases where plugins must be managed explicitly. In rare cases, it might also be necessary to install extra software on the Terraform worker, such as a configuration management tool or cloud CLI. ## Installing Terraform Providers The mechanics of provider installation changed in Terraform 0.13, thanks to the introduction of the [Terraform Registry][registry] for providers which allows custom and community providers to be installed via `terraform init`. Prior to Terraform 0.13, Terraform could only automatically install providers distributed by HashiCorp. ### Terraform 0.13 and later #### Providers From the Terraform Registry The [Terraform Registry][registry] allows anyone to publish and distribute providers which can be automatically downloaded and installed via `terraform init`. Terraform Enterprise instances must be able to access `registry.terraform.io` to use providers from the public registry; otherwise, you can install providers using [the `terraform-bundle` tool][bundle]. [registry]: https://registry.terraform.io/browse/providers #### In-House Providers If you have a custom provider that you'd rather not publish in the public Terraform Registry, you have a few options: - Add the provider binary to the VCS repo (or manually-uploaded configuration version). Place the compiled `linux\_amd64` version of the plugin at `terraform.d/plugins/////linux\_amd64`, relative to the root of the directory. The source host and namespace will need to match the source given in the `required\_providers` block within the configuration, but can otherwise be arbitrary identifiers. For instance, if your `required\_providers` block looks like this: ``` terraform { required\_providers { custom = { source = "my-host/my-namespace/custom" version = "1.0.0" } } } ``` HCP Terraform will be able to use your compiled provider if you place it at `terraform.d/plugins/my-host/my-namespace/custom/1.0.0/linux\_amd64/terraform-provider-custom`. - Use a privately-owned provider registry service which implements the [provider registry protocol](/terraform/internals/provider-registry-protocol) to distribute custom providers. Be sure to include the full [source address](/terraform/language/providers/requirements#source-addresses), including the hostname, when referencing providers. - \*\*Terraform Enterprise only:\*\* Use [the `terraform-bundle` tool][bundle] to add custom providers. -> \*\*Note:\*\* Using a [network mirror](/terraform/internals/provider-network-mirror-protocol) to host custom providers for installation is not currently supported in HCP Terraform, since the network mirror cannot be activated without a [`provider\_installation`](/terraform/cli/config/config-file#explicit-installation-method-configuration) block in the CLI configuration file. ### Terraform 0.12 and earlier #### Providers Distributed by HashiCorp HCP Terraform can automatically install providers distributed by HashiCorp. Terraform Enterprise instances can do this as well as long as they can access `releases.hashicorp.com`. If that isn't feasible due to security requirements, you can manually install providers. Use [the `terraform-bundle` tool][bundle] to build a custom version of Terraform that includes the necessary providers, and configure your workspaces to use that bundled version. [bundle]: https://github.com/hashicorp/terraform/tree/master/tools/terraform-bundle#installing-a-bundle-in-on-premises-terraform-enterprise #### Custom and Community Providers To use community providers or your own custom providers with Terraform versions prior to 0.13, you must install them yourself. There are two ways to accomplish this: - Add the provider binary to the VCS repo (or manually-uploaded configuration version) for any workspace that uses it. Place the compiled `linux\_amd64` version of the plugin at `terraform.d/plugins/linux\_amd64/` (as a relative path from the root of the working directory). The plugin name should follow the [naming scheme](/terraform/language/v1.1.x/configuration-0-11/providers#plugin-names-and-versions) and the plugin file must have read and execute permissions. (Third-party plugins are often distributed with an appropriate filename already set in the distribution archive.) You can add plugins directly to a configuration repo, or you can add them as Git submodules and symlink the executable files into `terraform.d/plugins/`. Submodules are a good choice when many workspaces use the same custom provider, since they keep your repos smaller. If using submodules, enable the ["Include submodules on clone" setting](/terraform/cloud-docs/workspaces/settings/vcs#include-submodules-on-clone) on any | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/install-software.mdx | main | terraform | [
0.009962871670722961,
-0.05981398746371269,
0.019637061282992363,
-0.023678112775087357,
-0.022389136254787445,
-0.04321237653493881,
-0.0333702452480793,
-0.044985875487327576,
0.01655876822769642,
0.05216743424534798,
0.015801768749952316,
-0.03639944642782211,
-0.014070011675357819,
0.0... | 0.080888 |
to a configuration repo, or you can add them as Git submodules and symlink the executable files into `terraform.d/plugins/`. Submodules are a good choice when many workspaces use the same custom provider, since they keep your repos smaller. If using submodules, enable the ["Include submodules on clone" setting](/terraform/cloud-docs/workspaces/settings/vcs#include-submodules-on-clone) on any affected workspace. - \*\*Terraform Enterprise only:\*\* Use [the `terraform-bundle` tool][bundle] to add custom providers to a custom Terraform version. This keeps custom providers out of your configuration repos entirely, and is easier to update when many workspaces use the same provider. ## Installing Additional Tools ### Avoid Installing Extra Software Whenever possible, don't install software on the worker. There are a number of reasons for this: - Provisioners are a last resort in Terraform; they greatly increase the risk of creating unknown states with unmanaged and partially-managed infrastructure, and the `local-exec` provisioner is especially hazardous. [The Terraform CLI docs on provisioners](/terraform/language/resources/provisioners/syntax#provisioners-are-a-last-resort) explain the hazards in more detail, with more information about the preferred alternatives. (In summary: use Packer, use cloud-init, try to make your infrastructure more immutable, and always prefer real provider features.) - We don't guarantee the stability of the operating system on the Terraform build workers. It's currently the latest version of Ubuntu LTS, but we reserve the right to change that at any time. - The build workers are disposable and are destroyed after each use, which makes managing extra software even more complex than when running Terraform CLI in a persistent environment. Custom software must be installed on every run, which also increases run times. ### Only Install Standalone Binaries HCP Terraform does not allow you to elevate a command's permissions with `sudo` during Terraform runs. This means you cannot install packages using the worker OS's normal package management tools. However, you can install and execute standalone binaries in Terraform's working directory. You have two options for getting extra software into the configuration directory: - Include it in the configuration repository as a submodule. (Make sure the workspace is configured to clone submodules.) - Use `local-exec` to download it with `curl`. For example: ```hcl resource "aws\_instance" "example" { ami = "${var.ami}" instance\_type = "t2.micro" provisioner "local-exec" { command = < \*\*Note:\*\* Terraform Enterprise instances can be configured to allow `sudo` commands during Terraform runs. However, even when `sudo` is allowed, using the worker OS's package tools during runs is still usually a bad idea. You will have a much better experience if you can move your provisioner actions into a custom provider or an immutable machine image. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/install-software.mdx | main | terraform | [
-0.04657858610153198,
-0.08485904335975647,
0.06855680048465729,
0.015866095200181007,
-0.020725419744849205,
-0.012000559829175472,
-0.013962149620056152,
-0.04266991466283798,
-0.0012086306232959032,
0.10191009193658829,
0.00005452343248180114,
-0.040563806891441345,
0.02122853882610798,
... | 0.028528 |
# UI and VCS-driven run workflow HCP Terraform has three workflows for managing Terraform runs. - The UI/VCS-driven run workflow described below, which is the primary mode of operation. - The [API-driven run workflow](/terraform/cloud-docs/workspaces/run/api), which is more flexible but requires you to create some tooling. - The [CLI-driven run workflow](/terraform/cloud-docs/workspaces/run/cli), which uses Terraform's standard CLI tools to execute runs in HCP Terraform. ## Summary In the UI and VCS workflow, every workspace is associated with a specific branch of a VCS repo of Terraform configurations. HCP Terraform registers webhooks with your VCS provider when you create a workspace, then automatically queues a Terraform run whenever new commits are merged to that branch of workspace's linked repository. HCP Terraform also performs a [speculative plan][] when a pull request is opened against that branch. HCP Terraform posts a link to the plan in the pull request, and re-runs the plan if the pull request is updated. [speculative plan]: /terraform/cloud-docs/workspaces/run/remote-operations#speculative-plans The Terraform code for a normal run always comes from version control, and is always associated with a specific commit. ## Automatically Starting Runs In a workspace linked to a VCS repository, runs start automatically when you merge or commit changes to version control. If you use GitHub as your VCS provider and merge a PR changing 300 or more files, HCP Terraform automatically triggers runs for every workspace connected to that repository. The GitHub API has a limit of 300 reported changed files for a PR merge. To address this, HCP Terraform initiates workspace runs proactively, preventing oversight of file changes beyond this limit. A workspace is linked to one branch of a VCS repository and ignores changes to other branches. You can specify which files and directories within your repository trigger runs. HCP Terraform can also automatically trigger runs when you create Git tags. Refer to [Automatic Run Triggering](/terraform/cloud-docs/workspaces/settings/vcs#automatic-run-triggering) for details. -> \*\*Note:\*\* A workspace with no runs will not accept new runs via VCS webhook. At least one run must be manually queued to confirm that the workspace is ready for further runs. A workspace will not process a webhook if the workspace previously processed a webhook with the same commit SHA and created a run. To trigger a run, create a new commit. If a workspace receives a webhook with a previously processed commit, HCP Terraform will add a new event to the [VCS Events](/terraform/cloud-docs/vcs#viewing-events) page documenting the received webhook. ## Manually Starting Runs You can manually trigger a run using the UI. Manual runs let you apply configuration changes when you update variable values but the configuration in version control is unchanged. You must manually trigger an initial run in any new VCS-driven workspace. -> \*\*Note:\*\* When you trigger a manual run, HCP Terraform does not fetch the latest commit from your VCS repository, and instead uses the current [configuration version](/terraform/cloud-docs/workspaces/configurations) associated with the workspace. HCP Terraform uses [VCS Webhooks](/terraform/cloud-docs/vcs#webhooks) to monitor changes in your VCS repository and update your configuration version. To start a run: 1. Sign in to [HCP Terraform](https://app.terraform.io/) or Terraform Enterprise and navigate to the workspace you want to start a run in. 1. Click \*\*+ New run\*\*, opening the \*\*Start a new run\*\* dialog. 1. Select the run mode and provide an optional message. Review the [run modes documentation](/terraform/cloud-docs/workspaces/run/modes-and-options) for more detail on supported options. Run modes that have a plan phase support debugging mode. This is equivalent to setting the `TF\_LOG` environment variable to `TRACE` for this run only. To enable debugging, click \*\*Additional planning options\*\* under the run mode and click \*\*Enable debugging mode\*\*. See [Debugging Terraform](/terraform/internals/debugging) for more information. To | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/ui.mdx | main | terraform | [
-0.05234444886445999,
0.007980040274560452,
0.00004199211616651155,
-0.023405417799949646,
-0.012978754937648773,
-0.0553162656724453,
-0.054111432284116745,
-0.06236414611339569,
0.06780635565519333,
0.04352429509162903,
-0.06915678828954697,
-0.075107641518116,
0.02472730167210102,
-0.03... | 0.137683 |
supported options. Run modes that have a plan phase support debugging mode. This is equivalent to setting the `TF\_LOG` environment variable to `TRACE` for this run only. To enable debugging, click \*\*Additional planning options\*\* under the run mode and click \*\*Enable debugging mode\*\*. See [Debugging Terraform](/terraform/internals/debugging) for more information. To [replace](/terraform/cloud-docs/workspaces/run/modes-and-options#replacing-selected-resources) specific resources as part of a standard plan and apply run, expand the \*\*Additional planning options\*\* section and select the resources to replace. Manually starting a run requires permission to queue plans for the workspace. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) [permissions-citation]: #intentionally-unused---keep-for-maintainers If the workspace has a plan that is still in the [plan stage](/terraform/cloud-docs/workspaces/run/states#the-plan-stage) when a new plan is queued, you can either wait for it to complete, or visit the \*\*Current Run\*\* page and click \*\*Run this plan now\*\*. Be aware that this action terminates the current plan and unlocks the workspace, which can lead to anomalies in behavior, but can be useful if the plans are long-running and the current plan does not have all the desired changes. ## Automatically cancel plan-only runs triggered by outdated commits Refer to [Automatically cancel plan-only runs triggered by outdated commits](/terraform/cloud-docs/users-teams-organizations/organizations/vcs-speculative-plan-management) for additional information. ## Confirming or Discarding Plans By default, run plans require confirmation before HCP Terraform will apply them. Users with permission to apply runs for the workspace can navigate to a run that has finished planning and click the "Confirm & Apply" or "Discard Plan" button to finish or cancel a run. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) If necessary, use the "View Plan" button for more details about what the run will change. [permissions-citation]: #intentionally-unused---keep-for-maintainers  Users can also leave comments if there's something unusual involved in a run. Note that once the plan stage is completed, until you apply or discard a plan, HCP Terraform can't start another run in that workspace. ### Auto apply If you would rather automatically apply plans that don't have errors, you can [enable auto apply](/terraform/cloud-docs/workspaces/settings#auto-apply-and-manual-apply) on the workspace's "General Settings" page. Some plans can't be auto-applied, like plans queued by [run triggers](/terraform/cloud-docs/workspaces/settings/run-triggers) or by users without permission to apply runs. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) [permissions-citation]: #intentionally-unused---keep-for-maintainers ## Speculative Plans on Pull Requests To help you review proposed changes, HCP Terraform can automatically run [speculative plans][speculative plan] for pull requests or merge requests. ### Viewing Pull Request Plans You can view speculative plans in a workspace's list of normal runs. Additionally, HCP Terraform adds a link to the run in the pull request itself, along with an indicator of the run's status. A single pull request can include links to multiple plans, depending on how many workspaces connect to the destination branch. If you update a pull request, HCP Terraform performs new speculative plans and update the links. Although any contributor to the repository can see the status indicators for pull request plans, only members of your HCP Terraform organization with permission to read runs for the affected workspaces can click through and view the complete plan output. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) [permissions-citation]: #intentionally-unused---keep-for-maintainers ### Rules for Triggering Pull Request Plans Whenever a pull request is \_created or updated,\_ HCP Terraform checks whether it should run speculative plans in workspaces connected to that repository, based on the following rules: - Only pull requests that originate from within the same repository can trigger speculative plans. To avoid executing malicious code or exposing sensitive information, HCP Terraform doesn't run speculative plans for pull requests that originate from forks of a repository. -> \*\*Note:\*\* On Terraform Enterprise, administrators can choose to allow speculative plans on pull requests that originate from forks. To learn more about this setting, refer to | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/ui.mdx | main | terraform | [
0.00500753428786993,
0.029742654412984848,
0.06651579588651657,
0.06513266265392303,
0.058983348309993744,
-0.08671413362026215,
-0.03469128534197807,
-0.11073978990316391,
0.021599918603897095,
0.11899527907371521,
-0.05428994446992874,
-0.035366132855415344,
-0.01576392538845539,
0.02321... | -0.007663 |
executing malicious code or exposing sensitive information, HCP Terraform doesn't run speculative plans for pull requests that originate from forks of a repository. -> \*\*Note:\*\* On Terraform Enterprise, administrators can choose to allow speculative plans on pull requests that originate from forks. To learn more about this setting, refer to the [general settings documentation](/terraform/enterprise/admin/application/general#allow-speculative-plans-on-pull-requests-from-forks) - Pull requests can only trigger runs in workspaces where automatic speculative plans are allowed. You can [disable automatic speculative plans](/terraform/cloud-docs/workspaces/settings/vcs#automatic-speculative-plans) in a workspace's VCS settings. - A pull request will only trigger speculative plans in workspaces that are connected to that pull request's destination branch. The destination branch is the branch that a pull request proposes to make changes to; this is often the repository's main branch, but not always. - If a workspace is configured to only treat certain directories in a repository as relevant, pull requests that don't affect those directories won't trigger speculative plans in that workspace. For more information, see [VCS settings: automatic run triggering](/terraform/cloud-docs/workspaces/settings/vcs#automatic-run-triggering). -> \*\*Note:\*\* If HCP Terraform skips a plan because the changes weren't relevant, it will still post a passing commit status to the pull request. - HCP Terraform does not update the status checks on a pull request with the status of an associated apply. This means that a commit with a successful plan but an errored apply will still show the passing commit status from the plan. ### Contents of Pull Request Plans Speculative plans for pull requests use the contents of the head branch (the branch that the PR proposes to merge into the destination branch), and they compare against the workspace's current state at the time of the plan. This means that if the destination branch changes significantly after the head branch is created, the speculative plan might not accurately show the results of accepting the PR. To get a more accurate view, you can rebase the head branch onto a more recent commit, or merge the destination branch into the head branch. ## Testing Terraform Upgrades with Speculative Plans You can start a new [speculative plan][speculative plan] in the UI with the workspace's current configuration version and any Terraform version available to the organization. 1. Sign in to [HCP Terraform](https://app.terraform.io/) or Terraform Enterprise and navigate to the workspace you want to try a new Terraform version in. 1. Click \*\*+ New run\*\*. 1. Select \*\*Plan only\*\* as the run type. 1. Select a version from the \*\*Choose Terraform version\*\* menu. The speculative plan will use this version without changing the workspace's settings. 1. Click \*\*Start run\*\*. If the run is successful, you can change the workspace's Terraform version and [upgrade the state](/terraform/cloud-docs/workspaces/state#upgrading-state). ## Speculative Plans During Development You can also use the CLI to run speculative plans on demand before making a pull request. Refer to the [CLI-driven run workflow](/terraform/cloud-docs/workspaces/run/cli#remote-speculative-plans) for more details. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/ui.mdx | main | terraform | [
-0.02232043817639351,
0.028750069439411163,
0.07271569222211838,
-0.02022801712155342,
-0.023041104897856712,
-0.03500301018357277,
0.0016007001977413893,
-0.051944512873888016,
0.04296331852674484,
0.08294220268726349,
-0.04059009253978729,
-0.059758611023426056,
0.00451116356998682,
-0.0... | 0.00578 |
# The API-driven run workflow HCP Terraform has three workflows for managing Terraform runs. - The [UI/VCS-driven run workflow](/terraform/cloud-docs/workspaces/run/ui), which is the primary mode of operation. - The API-driven run workflow described below, which is more flexible but requires you to create some tooling. - The [CLI-driven run workflow](/terraform/cloud-docs/workspaces/run/cli), which uses Terraform's standard CLI tools to execute runs in HCP Terraform. ## Summary In the API-driven workflow, workspaces are not directly associated with a VCS repo, and runs are not driven by webhooks on your VCS provider. Instead, one of your organization's other tools is in charge of deciding when configuration has changed and a run should occur. Usually this is something like a CI system, or something else capable of monitoring changes to your Terraform code and performing actions in response. Once your other tooling has decided a run should occur, it must make a series of calls to HCP Terraform's `runs` and `configuration-versions` APIs to upload configuration files and perform a run with them. For the exact series of API calls, see the [pushing a new configuration version](#pushing-a-new-configuration-version) section. The most significant difference in this workflow is that HCP Terraform \_does not\_ fetch configuration files from version control. Instead, your own tooling must upload the configurations as a `.tar.gz` file. This allows you to work with configurations from unsupported version control systems, automatically generate Terraform configurations from some other source of data, or build a variety of other integrations. ~> \*\*Important:\*\* The script below is provided to illustrate the run process, and is not intended for production use. If you want to drive HCP Terraform runs from the command line, please see the [CLI-driven run workflow](/terraform/cloud-docs/workspaces/run/cli). ## Pushing a New Configuration Version Pushing a new configuration to an existing workspace is a multi-step process. This section walks through each step in detail, using an example bash script to illustrate. You need queue plans permission to create new configuration versions for the workspace. Refer to the [permissions](/terraform/cloud-docs/users-teams-organizations/permissions/workspace) documentation for more details. [permissions-citation]: #intentionally-unused---keep-for-maintainers ### 1. Define Variables To perform an upload, a few user parameters must be set: - \*\*path\_to\_content\_directory\*\* is the folder with the terraform configuration. There must be at least one `.tf` file in the root of this path. - \*\*organization\*\* is the organization name (not ID) for your HCP Terraform organization. - \*\*workspace\*\* is the workspace name (not ID) in the HCP Terraform organization. - \*\*$TOKEN\*\* is the API Token used for [authenticating with the HCP Terraform API](/terraform/cloud-docs/api-docs#authentication). This script extracts the `path\_to\_content\_directory`, `organization`, and `workspace` from command line arguments, and expects the `$TOKEN` as an environment variable. ```bash #!/bin/bash if [ -z "$1" ] || [ -z "$2" ]; then echo "Usage: $0 /" exit 0 fi CONTENT\_DIRECTORY="$1" ORG\_NAME="$(cut -d'/' -f1 <<<"$2")" WORKSPACE\_NAME="$(cut -d'/' -f2 <<<"$2")" ``` ### 2. Create the File for Upload The [configuration version API](/terraform/cloud-docs/api-docs/configuration-versions) requires a `tar.gz` file to use the configuration version for a run, so you must package the directory containing the Terraform configuration into a `tar.gz` file. ~> \*\*Important:\*\* The configuration directory must be the root of the tar file, with no intermediate directories. In other words, when the tar file is extracted the result must be paths like `./main.tf` rather than `./terraform-appserver/main.tf`. ```bash UPLOAD\_FILE\_NAME="./content-$(date +%s).tar.gz" tar -zcvf "$UPLOAD\_FILE\_NAME" -C "$CONTENT\_DIRECTORY" . ``` ### 3. Look Up the Workspace ID The first step identified the organization name and the workspace name; however, the [configuration version API](/terraform/cloud-docs/api-docs/configuration-versions) expects the workspace ID. As such, the ID has to be looked up. If the workspace ID is already known, this step can be skipped. This step uses the [`jq` tool](https://stedolan.github.io/jq/) to | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/api.mdx | main | terraform | [
-0.059647176414728165,
0.009589887224137783,
0.015044262632727623,
-0.012914229184389114,
-0.02586883306503296,
-0.06507834047079086,
-0.08165481686592102,
-0.07520187646150589,
0.058338191360235214,
0.024187423288822174,
-0.06769493222236633,
-0.0934956818819046,
0.02712130919098854,
-0.0... | 0.090974 |
Workspace ID The first step identified the organization name and the workspace name; however, the [configuration version API](/terraform/cloud-docs/api-docs/configuration-versions) expects the workspace ID. As such, the ID has to be looked up. If the workspace ID is already known, this step can be skipped. This step uses the [`jq` tool](https://stedolan.github.io/jq/) to parse the JSON output and extract the ID value into the `WORKSPACE\_ID` variable. ```bash WORKSPACE\_ID=($(curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ https://app.terraform.io/api/v2/organizations/$ORG\_NAME/workspaces/$WORKSPACE\_NAME \ | jq -r '.data.id')) ``` ### 4. Create a New Configuration Version Before uploading the configuration files, you must create a `configuration-version` to associate uploaded content with the workspace. This API call performs two tasks: it creates the new configuration version and it extracts the upload URL to be used in the next step. ```bash echo '{"data":{"type":"configuration-versions"}}' > ./create\_config\_version.json UPLOAD\_URL=($(curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ --data @create\_config\_version.json \ https://app.terraform.io/api/v2/workspaces/$WORKSPACE\_ID/configuration-versions \ | jq -r '.data.attributes."upload-url"')) ``` ### 5. Upload the Configuration Content File Next, upload the configuration version `tar.gz` file to the upload URL extracted from the previous step. If a file is not uploaded, the configuration version will not be usable, since it will have no Terraform configuration files. HCP Terraform automatically creates a new run with a plan once the new file is uploaded. If the workspace is configured to auto-apply, it will also apply if the plan succeeds; otherwise, an apply can be triggered via the [Run Apply API](/terraform/cloud-docs/api-docs/run#apply). If the API token used for the upload lacks permission to apply runs for the workspace, the run can't be auto-applied. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) [permissions-citation]: #intentionally-unused---keep-for-maintainers ```bash curl \ --header "Content-Type: application/octet-stream" \ --request PUT \ --data-binary @"$UPLOAD\_FILE\_NAME" \ $UPLOAD\_URL ``` ### 6. Delete Temporary Files In the previous steps a few files were created; they are no longer needed, so they should be deleted. ```bash rm "$UPLOAD\_FILE\_NAME" rm ./create\_config\_version.json ``` ### Complete Script Combine all of the code blocks into a single file, `./terraform-enterprise-push.sh` and give execution permission to create a combined bash script to perform all of the operations. ```shell chmod +x ./terraform-enterprise-push.sh ./terraform-enterprise-push.sh ./content my-organization/my-workspace ``` \*\*Note\*\*: This script does not have error handling, so for a more robust script consider adding error checking. \*\*`./terraform-enterprise-push.sh`:\*\* ```bash #!/bin/bash # Complete script for API-driven runs. # 1. Define Variables if [ -z "$1" ] || [ -z "$2" ]; then echo "Usage: $0 /" exit 0 fi CONTENT\_DIRECTORY="$1" ORG\_NAME="$(cut -d'/' -f1 <<<"$2")" WORKSPACE\_NAME="$(cut -d'/' -f2 <<<"$2")" # 2. Create the File for Upload UPLOAD\_FILE\_NAME="./content-$(date +%s).tar.gz" tar -zcvf "$UPLOAD\_FILE\_NAME" -C "$CONTENT\_DIRECTORY" . # 3. Look Up the Workspace ID WORKSPACE\_ID=($(curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ https://app.terraform.io/api/v2/organizations/$ORG\_NAME/workspaces/$WORKSPACE\_NAME \ | jq -r '.data.id')) # 4. Create a New Configuration Version echo '{"data":{"type":"configuration-versions"}}' > ./create\_config\_version.json UPLOAD\_URL=($(curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request POST \ --data @create\_config\_version.json \ https://app.terraform.io/api/v2/workspaces/$WORKSPACE\_ID/configuration-versions \ | jq -r '.data.attributes."upload-url"')) # 5. Upload the Configuration Content File curl \ --header "Content-Type: application/octet-stream" \ --request PUT \ --data-binary @"$UPLOAD\_FILE\_NAME" \ $UPLOAD\_URL # 6. Delete Temporary Files rm "$UPLOAD\_FILE\_NAME" rm ./create\_config\_version.json ``` ## Advanced Use Cases For advanced use cases refer to the [Terraform Enterprise Automation Script](https://github.com/hashicorp/terraform-guides/tree/master/operations/automation-script) repository for automating interactions with HCP Terraform, including the creation of a workspace, uploading code, setting variables, and triggering the `plan` and `apply` operations. In addition to uploading configurations and starting runs, you can use HCP Terraform's APIs to create and modify workspaces, edit variable values, and more. See the [API documentation](/terraform/cloud-docs/api-docs) for more details. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/api.mdx | main | terraform | [
-0.0514521449804306,
0.05680328607559204,
-0.0016538426280021667,
0.03728650510311127,
-0.007177263963967562,
-0.025600122287869453,
-0.0278445016592741,
-0.06479642540216446,
0.06301391869783401,
0.07985293120145798,
-0.02365681156516075,
-0.06071856617927551,
0.04340564087033272,
0.00617... | 0.006556 |
the `plan` and `apply` operations. In addition to uploading configurations and starting runs, you can use HCP Terraform's APIs to create and modify workspaces, edit variable values, and more. See the [API documentation](/terraform/cloud-docs/api-docs) for more details. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/api.mdx | main | terraform | [
-0.022017434239387512,
0.003510167356580496,
0.01831471361219883,
0.023888785392045975,
-0.044634077697992325,
-0.0009253701427951455,
-0.06345144659280777,
-0.06311921775341034,
-0.030289635062217712,
0.11177391558885574,
-0.0423843152821064,
-0.03874310106039047,
0.052706360816955566,
-0... | 0.032236 |
# Run modes and options HCP Terraform runs support many of the same modes and options available in the Terraform CLI. ## Plan and Apply (Standard) 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. - \*\*CLI:\*\* Use `terraform apply` (without providing a saved plan file). - \*\*API:\*\* Create a run without specifying any options that select a different mode. - \*\*UI:\*\* From the workspace's overview page, click \*\*+ New run\*\*, and then choose \*\*Plan and apply (standard)\*\* as the run type. - \*\*VCS:\*\* When a workspace is connected to a VCS repository, HCP Terraform automatically starts a standard plan and apply when you add new commits to the selected branch of that repository. ## Destroy Mode [Destroy mode](/terraform/cli/commands/plan#planning-modes) instructs Terraform to create a plan which destroys all objects, regardless of configuration changes. - \*\*CLI:\*\* Use `terraform plan -destroy` or `terraform destroy` - \*\*API:\*\* Use the `is-destroy` option. - \*\*UI:\*\* Use a workspace's \*\*Destruction and Deletion\*\* settings page. ## Plan Only/Speculative Plan This option creates a [speculative plan](/terraform/cloud-docs/workspaces/run/remote-operations#speculative-plans). 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. - \*\*API:\*\* Set the `plan-only` option to `true` and specify an available terraform version using the `terraform-version` field. - \*\*UI:\*\* From the workspace's overview page, click \*\*+ New run\*\*, and then choose \*\*Plan only\*\* as the run type. - \*\*VCS:\*\* When a workspace is connected to a VCS repository, HCP Terraform automatically starts a speculative plan when someone opens a pull request (or merge request) against the selected branch of that repository. The pull/merge request view in your VCS links to the speculative plan, and you can also find it in the workspace's run list. ## Saved Plans -> \*\*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. - \*\*CLI:\*\* Use `terraform plan -out ` to perform and save a plan, then use | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/modes-and-options.mdx | main | terraform | [
-0.02304874174296856,
0.0420602485537529,
0.059731870889663696,
0.0031451652757823467,
-0.008304878138005733,
-0.02312651462852955,
-0.05245143175125122,
-0.06685500591993332,
0.024846086278557777,
0.07364488393068314,
-0.03802910074591637,
-0.06739185005426407,
0.030736291781067848,
-0.02... | 0.02151 |
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. - \*\*CLI:\*\* Use `terraform plan -out ` to perform and save a plan, then use `terraform apply ` to apply the saved plan. Use `terraform show ` to inspect a saved plan before applying it. - \*\*API:\*\* Use the `save-plan` option when creating a run. If you create a new configuration version for a saved plan run, use the `provisional` option so that it will not become the workspace's current configuration version until you decide to apply the run. ## Allow Empty Apply 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. - \*\*API:\*\* Set the `allow-empty-apply` field to `true`. - \*\*UI:\*\* From the workspace's overview page, click \*\*+ New run\*\*, and then choose \*\*Allow empty apply\*\* as the run type. ## Refresh-Only Mode > \*\*Hands-on:\*\* Try the [Use Refresh-Only Mode to Sync Terraform State](/terraform/tutorials/state/refresh) tutorial. -> \*\*Version note:\*\* Refresh-only support requires a workspace using at least Terraform CLI v0.15.4. [Refresh-only mode](/terraform/cli/commands/plan#planning-modes) 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. - \*\*CLI:\*\* Use `terraform plan -refresh-only` or `terraform apply -refresh-only`. - \*\*API:\*\* Use the `refresh-only` option. - \*\*UI:\*\* From the workspace's overview page, click \*\*+ New run\*\*, and then choose \*\*Refresh state\*\* as the run type. ## Skipping Automatic State Refresh The [`-refresh=false` option](/terraform/cli/commands/plan#refresh-false) is used in normal planning mode to skip the default behavior of refreshing Terraform state before checking for configuration changes. - \*\*CLI:\*\* Use `terraform plan -refresh=false` or `terraform apply -refresh=false`. - \*\*API:\*\* Use the `refresh` option. ## Replacing Selected Resources -> \*\*Version note:\*\* Replace support requires a workspace using at least Terraform CLI v0.15.2. The [replace option](/terraform/cli/commands/plan#replace-address) instructs Terraform to replace the object with the given resource address. - \*\*CLI:\*\* Use `terraform plan -replace=ADDRESS` or `terraform apply -replace=ADDRESS`. - \*\*API:\*\* Use the `replace-addrs` option. - \*\*UI:\*\* Click \*\*+ New run\*\* and select the \*\*Plan and apply (standard)\*\* run type. Then click \*\*Additional planning options\*\* to reveal the \*\*Replace resources\*\* option. Type the address of the resource that you want to replace. You can replace multiple resources. ## Targeted Plan and Apply [Resource Targeting](/terraform/cli/commands/plan#resource-targeting) is intended for exceptional circumstances only and should not be used routinely. - \*\*CLI:\*\* Use `terraform plan -target=ADDRESS` or `terraform apply -target=ADDRESS`. - \*\*API:\*\* Use the `target-addrs` option. The usual caveats for targeting in local operations imply some additional limitations on HCP Terraform features for remote plans created with targeting: - [Sentinel](/terraform/cloud-docs/policy-enforcement) policy checks for targeted plans will see only the selected subset of resource instances planned for changes in [the `tfplan` import](/terraform/cloud-docs/policy-enforcement/import-reference/tfplan-v2) and [the `tfplan/v2` import](/terraform/cloud-docs/policy-enforcement/import-reference/tfplan-v2), which may cause an unintended failure for any policy | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/modes-and-options.mdx | main | terraform | [
-0.0381152480840683,
0.06229327991604805,
0.03187571465969086,
-0.028930051252245903,
-0.03510836884379387,
0.014399653300642967,
-0.05746304616332054,
-0.06897305697202682,
0.002312152646481991,
0.03805175796151161,
-0.0632895678281784,
-0.07144483923912048,
0.04480931907892227,
-0.032142... | 0.032398 |
imply some additional limitations on HCP Terraform features for remote plans created with targeting: - [Sentinel](/terraform/cloud-docs/policy-enforcement) policy checks for targeted plans will see only the selected subset of resource instances planned for changes in [the `tfplan` import](/terraform/cloud-docs/policy-enforcement/import-reference/tfplan-v2) and [the `tfplan/v2` import](/terraform/cloud-docs/policy-enforcement/import-reference/tfplan-v2), which may cause an unintended failure for any policy that requires a planned change to a particular resource instance selected by its address. - [Cost Estimation](/terraform/cloud-docs/cost-estimation) is disabled for any run created with `-target` set, to prevent producing a misleading underestimate of cost due to resource instances being excluded from the plan. You can disable or constrain use of targeting in a particular workspace using a Sentinel policy based on [the `tfrun.target\_addrs` value](/terraform/cloud-docs/policy-enforcement/import-reference/tfrun#value-target\_addrs). ## Generating Configuration -> \*\*Version note:\*\* Support for `import` blocks and generating configuration requires a workspace using at least Terraform CLI v1.5.0. When using [`import` blocks](/terraform/language/import) to import existing resources, Terraform can [automatically generate configuration](/terraform/language/import/generating-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. - \*\*CLI:\*\* Use `terraform plan -generate-config-out=generated.tf`. - \*\*API:\*\* Use the `allow-config-generation` option. 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. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/modes-and-options.mdx | main | terraform | [
-0.0027099016588181257,
0.034395575523376465,
0.05357183516025543,
0.018630806356668472,
0.10829481482505798,
-0.024121800437569618,
0.025817502290010452,
-0.06523700803518295,
0.025978444144129753,
0.07537520676851273,
-0.03358243405818939,
-0.0785595029592514,
0.04615674167871475,
0.0034... | 0.021352 |
# Manage and view runs Each workspace in HCP Terraform includes a list of its current, pending, and historical runs. You can view and interact with these runs in the UI. You can also lock workspaces to temporarily prevent new runs. ## API Refer to the [Runs API](/terraform/cloud-docs/api-docs/run) and [lock a Workspace endpoint](/terraform/cloud-docs/api-docs/workspaces#lock-a-workspace). ## Navigating Runs Go to the workspace and click the \*\*Runs\*\* tab to review a list of all current and past Terraform runs. Click a run to go to its details page. The details page contains the following information: - The current status of the run. - The code commit associated with the run. - How the run initiated, when, and which user initiated it (if applicable). - A timeline of events related to the run. - The output from both the `terraform plan` and `terraform apply` commands, if applicable. This output defaults to visible if the command is currently running and hidden if the command has finished. ### Action runs HCP Terraform identifies runs that invoke actions on the run details page. Actions are preset operations built into providers that you can invoke to trigger automations outside of Terraform, such as Ansible playbooks and Lambda jobs. Refer to [Invoke an action](/terraform/language/invoke-actions) in the Terraform configuration language documentation for more information. HCP Terraform indicates how many actions the run invoked and adds \*\*action:\*\* labels to the \*\*Plan\*\* operation output and \*\*Invoked:\*\* labels to the \*\*Apply\*\* operation output. You can invoke actions either as part of a resource lifecycle configuration or manually target a specific action using the `-invoke` flag to a `terraform apply` or `terraform plan` command. A Standard tier subscription is required to use the `-invoke` flag to execute an action and to view details about action runs that were invoked from the command line using the `-invoke` flag. Refer to the [Terraform pricing page](https://www.hashicorp.com/en/pricing?tab=terraform) for more information. ## Interacting with Runs In workspaces where you have [permission to apply runs](/terraform/cloud-docs/users-teams-organizations/permissions/workspace), you can interact with a run at the bottom of its details page. The following options are available, depending on the state of the run: | Button | Available when: | | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Add Comment | Always. | | Confirm & Apply | A plan needs confirmation. | | Override & Continue | A soft-mandatory policy failed. Requires permission to manage policy overrides for the organization. | | Discard Run | A plan needs confirmation or a soft-mandatory policy failed. | | Cancel Run | A plan or apply is currently running. | | Force Cancel Run | A plan or apply canceled, but HCP Terraform was unable to end the run. Requires admin access to the workspace. | | Retry Run | A plan-only run has finished. You can also change which Terraform version to use when retrying a plan-only run. | [permissions-citation]: #intentionally-unused---keep-for-maintainers If a plan needs confirmation (with [manual apply](/terraform/cloud-docs/workspaces/settings#auto-apply-and-manual-apply) enabled) or a soft-mandatory policy failed, the run remains paused until a user with appropriate permissions uses these buttons to continue or discard the run. Refer to [Run States and Stages](/terraform/cloud-docs/workspaces/run/states) for more details. ### Canceling Runs If a run is currently planning or applying, users with [permission to apply runs](/terraform/cloud-docs/users-teams-organizations/permissions/workspace) for the workspace can click \*\*Cancel Run\*\* to stop the run before it finishes. [permissions-citation]: #intentionally-unused---keep-for-maintainers Canceling a run is roughly equivalent to typing `ctrl+c` during a Terraform plan or apply on the CLI. The running Terraform process is sent an INT signal, which instructs Terraform to end its work, update state for any resources that have already been changed, and wrap up in the safest way | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/manage.mdx | main | terraform | [
-0.021752947941422462,
0.0037107327952980995,
0.01741785928606987,
0.021706413477659225,
0.03855011612176895,
0.010239532217383385,
-0.058381251990795135,
-0.10840854793787003,
0.022227594628930092,
0.09440243989229202,
-0.04156899452209473,
-0.04183143377304077,
0.008035900071263313,
-0.0... | 0.051862 |
a run is roughly equivalent to typing `ctrl+c` during a Terraform plan or apply on the CLI. The running Terraform process is sent an INT signal, which instructs Terraform to end its work, update state for any resources that have already been changed, and wrap up in the safest way possible. In rare cases, a canceled run can fail to end, continuing to lock the workspace. You can forcefully cancel these runs, which immediately terminates the running Terraform process and unlocks the workspace. Force-canceling requires admin access to the workspace because it can have dangerous side-effects, including loss of state and orphaned resources. Additionally, the \*\*Force Cancel Run\*\* button only appears after you click \*\*Cancel Run\*\* and HCP Terraform has time to terminate the run safely. [permissions-citation]: #intentionally-unused---keep-for-maintainers ## Locking Workspaces (Preventing Runs) You can lock the workspace to temporarily stop runs from proceeding. Locking a workspace requires [permission to lock and unlock the workspace](/terraform/cloud-docs/users-teams-organizations/permissions/workspace), and requires that the workspace is not currently locked by an in-progress run. A lock prevents HCP Terraform from performing any applies in the workspace, and also prevents many kinds of plans. New runs remain in the \*\*Pending\*\* state until the workspace unlocks. Locking \*\*does not\*\* affect [plan-only runs](/terraform/cloud-docs/workspaces/run/remote-operations#speculative-plans) or the planning stages of [saved plan runs](/terraform/cloud-docs/workspaces/run/cli#remote-saved-plans). Terraform allows these types of runs because they can not affect infrastructure resources, do not attempt to lock the workspace themselves, and might provide important information about tasks to perform before removing the lock. Note that you can not \_apply\_ saved-plan runs while the workspace is locked, and HCP Terraform automatically discards these runs if the workspace's state is changed before they can be applied. Terraform Enterprise does not yet support saved plans. HCP Terraform shows the lock status in the workspace's header, next to the \*\*Actions\*\* menu. To lock or unlock a workspace, do one of the following: - Open the \*\*Actions\*\* menu and select \*\*Lock workspace\*\* or \*\*Unlock workspace\*\*. - Go to \*\*Settings > Locking\*\*. [permissions-citation]: #intentionally-unused---keep-for-maintainers | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/run/manage.mdx | main | terraform | [
-0.027974415570497513,
0.04594583064317703,
0.05637718364596367,
0.021862894296646118,
0.0006300135282799602,
-0.010952888987958431,
-0.038279008120298386,
-0.1152484342455864,
0.058353159576654434,
0.09463084489107132,
-0.029874658212065697,
-0.006307561881840229,
0.013712888583540916,
-0... | 0.071306 |
# Design no-code ready modules Terraform [modules](/terraform/language/modules) let you define standardized collections of infrastructure resources that downstream users can more easily deploy. No-code ready modules build on these advantages by letting users deploy a module's resources without writing any Terraform configuration. This practice is called no-code provisioning. @include 'tfc-package-callouts/nocode.mdx' No-code provisioning enables a self-service workflow that lets users provision approved collections of resources without learning Terraform or infrastructure best practices. You can enable no-code provisioning for any public or private module in your [private registry](/terraform/cloud-docs/registry). Users can then [provision no-code infrastructure](/terraform/cloud-docs/workspaces/no-code-provisioning/provisioning), set the module's input variables, and deploy its resources. > \*\*Hands On:\*\* Try the [Create and Use No-Code Ready Modules tutorial](/terraform/tutorials/cloud/no-code-provisioning). The same best practices apply to both standard and no-code ready module design. However, no-code modules have additional requirements and considerations. ## Requirements A no-code ready module must meet the following requirements: - \*\*Root Module Structure:\*\* The module must follow [standard module structure](/terraform/language/modules/develop/structure) and define its resources in the root directory of the repository. This structure allows the public and private registries to generate documentation, track resource usage, and parse submodules and examples. - \*\*Provider Configuration:\*\* A no-code ready module must declare the required provider(s) directly in the module. This configuration differs from the recommendations for [modules used in written configuration](/terraform/language/modules/develop/providers#legacy-shared-modules-with-provider-configurations). ### Provider credentials Organization administrators must determine how no-code workspaces access credentials for provider authentication and design modules accordingly. When module consumers follow the no-code workflow, HCP Terraform automatically creates a new workspace for the resources and attempts to provision them. New workspaces must be able to access credentials for all providers defined within the module. You can grant new no-code workspace provider credentials using one of the following methods: - Recommended: Create a [project-scoped variable set](/terraform/cloud-docs/variables/managing-variables#variable-sets) that HCP Terraform applies to all existing and future workspaces within a project. This approach allows you to create specific teams for those less familiar with Terraform, then give those teams access to your no-code projects. - Create a [global variable set](/terraform/cloud-docs/variables/managing-variables#variable-sets) that HCP Terraform applies to all existing and future workspaces in the organization. This action automatically grants newly-created workspaces access to the required provider credentials. - Expose provider credentials as sensitive outputs in another workspace. You must add additional configuration to the module to access these values through [remote state data sources](/terraform/language/state/remote-state-data) and then reference them in provider configuration. This approach provides more control over access to these credentials than placing them in a global variable set. - Elect to let the first run in new no-code workspaces fail and have module users add credentials directly to the workspace after creation. This approach provides the most control over access to provider credentials, but requires manual intervention. Module users must manually start a new run to provision infrastructure after they configure the credentials. ## Module Design Recommendations Similarly to a [standard module](/terraform/language/modules/develop#when-to-write-a-module), a well-designed no-code ready module composes resources so that they are easy for others to deploy. However, no-code module users are less familiar with Terraform, so we recommend the following best practices for no-code module design. ### Build For a Specific Use Case No-code ready module users are typically less familiar with Terraform and infrastructure management. Reduce the amount of technical decision-making required to deploy the module by scoping it to a single, specific use case. This approach lets users focus on business concerns instead of infrastructure concerns. For example, you could build modules that satisfy the following well-scoped use cases: - Deploying all resources needed for a three-tier web application - Deploying a database with constraints on resource allocation and deployment region ### Updating a Module's | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/no-code-provisioning/module-design.mdx | main | terraform | [
-0.006423213053494692,
-0.018289191648364067,
-0.03200783208012581,
-0.015558727085590363,
-0.033994127064943314,
-0.025629235431551933,
-0.04254378750920296,
-0.06783922761678696,
0.001985666574910283,
0.061677541583776474,
0.012926719151437283,
-0.031214168295264244,
0.03394618630409241,
... | 0.029075 |
approach lets users focus on business concerns instead of infrastructure concerns. For example, you could build modules that satisfy the following well-scoped use cases: - Deploying all resources needed for a three-tier web application - Deploying a database with constraints on resource allocation and deployment region ### Updating a Module's Version When you enable no-code provisioning for a module, HCP Terraform pins the \*\*No-code Ready\*\* designation to the specific module version of your choice. HCP Terraform deploys that selected module version whenever a user provisions a workspace using that module, ensuring that no-code users always provision the correct version. Pinning the \*\*No-code Ready\*\* designation to a specific module version lets you set variable input options, which are tied to that specific module version. By default, a module selects the latest version available. If you pinned a specific module version and a newer one becomes available, you can always update your module's version. ### Provide Variable Defaults When Possible The no-code provisioning workflow prompts users to set values for the module version's input variables before creating the new workspace and deploying resources. We recommend setting reasonable defaults when possible to reduce the effort and expertise needed to deploy the module. Remember that the workspace can also access variable values set through global or project level variable sets in your organization. ### Define Dropdown Options for Variables without Defaults If your module has variables without defaults, you can define options to limit the values a user can input when you enable a module for no-code provisioning. You can define input options using the HCP Terraform UI, the [No-Code Provisioning API](/terraform/cloud-docs/api-docs/no-code-provisioning), or the [TFE provider](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/no\_code\_module). We recommend using the TFE provider if you want to track variable input options through a code approval process, therefore keeping your configuration as code. HCP Terraform surfaces any subsequent changes to a variableβs input options when no-code users provision a new module version. If you update the selected module version enabled for no-code provisioning, consider revisiting the variables and adjusting the defined input values accordingly. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/no-code-provisioning/module-design.mdx | main | terraform | [
-0.034428179264068604,
0.012401487678289413,
0.025897569954395294,
-0.025880757719278336,
-0.012857280671596527,
0.0007927600527182221,
-0.029895322397351265,
-0.06478717923164368,
-0.05833250284194946,
0.017351776361465454,
0.004117228090763092,
-0.0572483204305172,
0.03109482116997242,
-... | 0.000697 |
# Provision no-code infrastructure No-code provisioning lets you deploy infrastructure resources in a new HCP Terraform workspace without writing any Terraform configuration. You can create a no-code workspace from any module version labeled \*\*No-code Ready\*\* in your organization's [private registry](/terraform/cloud-docs/registry). @include 'tfc-package-callouts/nocode.mdx' > \*\*Hands On:\*\* Try the [Create and Use No-Code Ready Modules tutorial](/terraform/tutorials/cloud/no-code-provisioning). ## Permissions To use no-code provisioning, you must be a member of a team with [manage all projects permissions](/terraform/cloud-docs/users-teams-organizations/permissions/organization#manage-all-projects), [manage all workspaces permissions](/terraform/cloud-docs/users-teams-organizations/permissions/organization#manage-all-workspaces), or [admin permissions for a project](/terraform/cloud-docs/users-teams-organizations/permissions/project#project-admin). When using [custom project permissions](/terraform/cloud-docs/users-teams-organizations/permissions/project), your team must be able to create workspaces, write variables, and apply runs in a project. ## Provider Credentials Terraform automatically starts a new run to provision no-code infrastructure upon workspace creation. No-code modules contain provider blocks in their configuration, but still require provider credentials for successful deployment. Organization administrators determine how new workspaces should [access provider credentials](/terraform/cloud-docs/workspaces/no-code-provisioning/module-design#provider-credentials), which may require specific module design. ## Creating a Workspace and Deploying Resources The no-code provisioning workflow creates a new HCP Terraform workspace to deploy and manage the no-code ready module's resources. HCP Terraform automatically starts a run to provision the module's resources in the new workspace. Depending on the workspace's settings, Terraform either automatically applies the plan or prompts you for approval to provision the infrastructure. To launch the no-code workflow: 1. Sign in to [HCP Terraform](https://app.terraform.io/) or Terraform Enterprise and navigate to the organization with the module you want to provision. 1. Click \*\*Registry\*\* in the main HCP Terraform navigation to access your organization's private registry. 1. Click \*\*Modules\*\* to view the list of available modules in the private registry. You can filter for no-code ready modules in your registry. No-code enabled modules have a \*\*No-code Ready\*\* badge next to their names. 1. Select the no-code ready module to view its details, then click \*\*Provision workspace\*\*. The \*\*Configure module inputs\*\* page appears. HCP Terraform scans the module configuration for input variables and prompts for values for any variables without defaults or undefined in an existing global variable set. Terraform requires values for these variables to successfully complete runs in the workspace. HCP Terraform performs type validation for the variable values if the module configuration specifies a type. 1. (Optional) Set values for the input variables. If your organization has defined options for a variable's values, these options appear in a dropdown menu. You can skip this step and configure the variables later in your workspace. However, HCP Terraform does not prompt you for these values again, and your Terraform runs may fail. 1. Click \*\*Next: Workspace settings\*\*. 1. Enter a \*\*Workspace Name\*\*. The name must be unique within the organization and can include letters, numbers, dashes (-), and underscores (\_). Refer to the [workspace naming recommendations](/terraform/cloud-docs/workspaces/create#workspace-naming) for more guidance. 1. Choose a \*\*Project\*\* for the workspace. Teams with access to the specified project can view the workspace automatically. Refer to [Organizing Workspaces with Projects](/terraform/cloud-docs/projects/manage) for more details. If the specified project contains any project-scoped variable sets, HCP Terraform automatically applies those sets to the workspace. 1. Add an optional \*\*Description\*\* for the workspace. 1. Select an apply method for the workspace. \*\*Auto apply\*\* automatically applies any successful runs in the workspace, including the initial run on workspace creation. \*\*Manual apply\*\* prompts operators to review and confirm the changes in a run. \*\*Auto apply\*\* is the default option for a no-code workspace. 1. Click \*\*Create workspace\*\*. HCP Terraform creates a new workspace and starts a run. Depending on the apply method, it automatically applies your infrastructure or prompts you for approval to create the no-code module's resources. ## Operations in No-Code Workspaces No-code | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/no-code-provisioning/provisioning.mdx | main | terraform | [
-0.015243055298924446,
-0.05370893329381943,
-0.025696715340018272,
-0.02792462706565857,
-0.03707705810666084,
-0.015352933667600155,
-0.0756039246916771,
-0.07354384660720825,
-0.007119668647646904,
0.08101750165224075,
0.00875464640557766,
-0.07233677804470062,
0.036513566970825195,
-0.... | 0.002408 |
apply\*\* is the default option for a no-code workspace. 1. Click \*\*Create workspace\*\*. HCP Terraform creates a new workspace and starts a run. Depending on the apply method, it automatically applies your infrastructure or prompts you for approval to create the no-code module's resources. ## Operations in No-Code Workspaces No-code workspaces have a limited feature set because you cannot access the resource configuration. However, you can edit workspace variables and settings, including notifications, permissions, and run triggers. You can use run triggers to connect the workspace to one or more source workspaces, start new runs when you change workspace variables, or queue destroy runs. ### Updating Variables To change a variable's options after provisioning, go to the \*\*Variables\*\* section in your workspace to see your workspace's variables listed. To edit a variable: 1. Click the ellipses next to the variable you want to edit and select \*\*Edit\*\*. 2. Enter your desired value and click \*\*Save variable\*\*. Start a new run in your workspace to update your existing infrastructure with your new variable value. ### Module Version Updates When you [update the module version](/terraform/cloud-docs/workspaces/no-code-provisioning/module-design#updating-a-module-s-version) designated for no-code provisioning, every workspace provisioned from the module is notified that an updated version is available on the workspace overview page. HCP Terraform does not automatically update workspaces. A workspace admin must respond to the update notification to upgrade the workspace, and HCP Terraform prompts for values for any new input variables. To change the version of the module that users can deploy: 1. Sign in to [HCP Terraform](https://app.terraform.io/) or Terraform Enterprise and navigate to your organization. 1. Choose \*\*Registry\*\* from the sidebar and navigate to the module in your organization's registry. 1. Click \*\*Configure Settings\*\*. 1. Click \*\*Edit version and variable options\*\*. 1. Choose the desired module version from the \*\*Module version\*\* dropdown. 1. Click \*\*Save\*\*. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/workspaces/no-code-provisioning/provisioning.mdx | main | terraform | [
-0.029743969440460205,
-0.014371034689247608,
-0.016426917165517807,
0.04740230366587639,
-0.027624696493148804,
0.022818032652139664,
-0.008770636282861233,
-0.09916302561759949,
-0.024914810433983803,
0.05610593408346176,
-0.0026966670993715525,
-0.06777139008045197,
0.04671693965792656,
... | 0.029554 |
# API Tokens This topic describes the distinct types of API tokens you can use to authenticate with HCP Terraform. Note that HCP Terraform only displays API tokens once when you initially create them and are obfuscated thereafter. If the token is lost, it must be regenerated. Refer to [Team Token API](/terraform/cloud-docs/api-docs/team-tokens) and [Organization Token API](/terraform/cloud-docs/api-docs/organization-tokens) for additional information about using the APIs. ## User API Tokens API tokens may belong directly to a user. User tokens are the most flexible token type because they inherit permissions from the user they are associated with. For more information on user tokens and how to generate them, see the [Users](/terraform/cloud-docs/users-teams-organizations/users#tokens) documentation. ### Disable user tokens for organizations By default, user tokens are enabled for organizations. When your organization disables user tokens, the HCP Terraform API blocks user tokens from accessing organization resources. To disable user tokens for your organization, perform the following steps: 1. Sign in to [HCP Terraform](https://app.terraform.io/) or Terraform Enterprise, then navigate to the organization where you want to disable user tokens. 1. Choose \*\*Settings\*\* from the sidebar, then \*\*API tokens\*\*. 1. From the \*\*User Tokens\*\* tab, uncheck the \*\*Allow members to access organization resources with their user tokens\*\* setting. 1. Click \*\*Update settings\*\*. 1. In the confirmation modal, select \*\*Disable\*\*. 1. User tokens are now disabled for this organization. If your organization has automations that authenticate using user tokens, disabling user tokens can cause those automations to fail. An organization that disables user tokens cannot connect to VCS using the [Github (App)](/terraform/cloud-docs/vcs/github-app), because it relies on user tokens to authenticate. Your organization can use [Github (OAuth) to configure their VCS connections](/terraform/cloud-docs/vcs/github) instead. ## Team API Tokens In HashiCorp Cloud Platform (HCP) Europe organizations, you manage user access through HCP groups. Instead of using team API tokens, you use group tokens. Refer to [group tokens](#group-api-tokens) to learn more. API tokens may belong to a specific team. Team API tokens allow access to the workspaces that the team has access to, without being tied to any specific user. Navigate to the \*\*Organization Settings > API Tokens > Team Tokens\*\* tab to manage API tokens for a team or create new team tokens. Teams can have multiple valid tokens at a time, so long as the tokens' descriptions are unique within the context of the given team. A token without a description is considered a legacy token, and only one legacy token can exist at a given time. The [legacy API](/terraform/cloud-docs/api-docs/team-tokens#legacy-team-tokens-api-reference) uses a legacy token, generating a new legacy token invalidates the previous token. The [current team token API](/terraform/cloud-docs/api-docs/team-tokens#team-tokens-api-reference) supports multiple team tokens, and adding new tokens does not invalidate older ones. Owners and users with [manage teams](/terraform/cloud-docs/users-teams-organizations/permissions/organization#manage-teams) permissions have the ability to enable and disable team token management for a team, which limits the actions that team members can take on a team token. Refer to [Allow Member Token Management](/terraform/cloud-docs/users-teams-organizations/permissions/organization#allow-member-token-management) for more information. Team API tokens are designed for performing API operations on workspaces. They have the same access level to the workspaces the team has access to. For example, if a team has permission to apply runs on a workspace, the team's token can create runs and configuration versions for that workspace via the API. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) [permissions-citation]: #intentionally-unused---keep-for-maintainers Note that the individual members of a team can usually perform actions the team itself cannot, since users can belong to multiple teams, can belong to multiple organizations, and can authenticate with Terraform's `atlas` backend for running Terraform locally. If an API token is generated for the "owners" team, then that API token will have all of the same permissions | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/api-tokens.mdx | main | terraform | [
-0.05334385111927986,
0.02112750895321369,
0.06125481799244881,
-0.01626928150653839,
-0.015363669022917747,
0.0011317896423861384,
0.022595670074224472,
-0.040989428758621216,
0.02868051454424858,
0.01986047998070717,
-0.06519491225481033,
-0.0566365122795105,
0.052177347242832184,
0.0054... | 0.077903 |
perform actions the team itself cannot, since users can belong to multiple teams, can belong to multiple organizations, and can authenticate with Terraform's `atlas` backend for running Terraform locally. If an API token is generated for the "owners" team, then that API token will have all of the same permissions that an organization owner would. ## Group API Tokens In HashiCorp Cloud Platform (HCP) Europe organizations, you manage user access through HCP groups. If your URL includes `portal.cloud.eu.hashicorp` or `app.eu.terraform.io`, then you are in an HashiCorp Cloud Platform (HCP) Europe organization. If you are not in an HCP Europe organization, refer to [team API tokens](#team-api-tokens). For those familiar with teams in HCP Terraform organizations, group tokens in HCP Europe organizations are interchangeable with team tokens. Group API tokens may belong to a specific group. Group API tokens allow access to the workspaces that the group has access to, without being tied to any specific user. Navigate to the \*\*Organization Settings > API Tokens > Group Tokens\*\* tab to manage API tokens for a group or create new group tokens. Groups can have multiple valid tokens at a time, so long as the tokens' descriptions are unique within the context of the given group. Those with [\*\*Manage groups\*\*](/terraform/cloud-docs/users-teams-organizations/permissions/organization#group-permissions) permissions can enable and disable group token management for a group, which limits the actions that group members can take on a group token. Refer to [Allow Member Token Management](/terraform/cloud-docs/users-teams-organizations/permissions/organization#allow-member-token-management) for more information. Group API tokens are designed for performing API operations on workspaces. They have the same access level to the workspaces the group has access to. For example, if a group has permission to apply runs on a workspace, the group's token can create runs and configuration versions for that workspace via the API. ([More about permissions.](/terraform/cloud-docs/users-teams-organizations/permissions)) [permissions-citation]: #intentionally-unused---keep-for-maintainers Note that the individual members of a group can usually perform actions the group itself cannot, because users can belong to multiple groups. ## Organization API Tokens API tokens may be generated for a specific organization. Organization API tokens allow access to the organization-level settings and resources, without being tied to any specific team or user. To manage the API token for an organization, go to \*\*Organization settings > API Token\*\* and use the controls under the "Organization Tokens" header. Each organization can have \*\*one\*\* valid API token at a time. Only [organization owners](/terraform/cloud-docs/users-teams-organizations/teams#the-owners-team) can generate or revoke an organization's token. [permissions-citation]: #intentionally-unused---keep-for-maintainers Organization API tokens are designed for creating and configuring workspaces and teams. We don't recommend using them as an all-purpose interface to HCP Terraform; their purpose is to do some initial setup before delegating a workspace to a team. For more routine interactions with workspaces, use [team API tokens](#team-api-tokens). Organization API tokens have permissions across the entire organization. They can perform all CRUD operations on most resources, but have some limitations; most importantly, they cannot start runs or create configuration versions. Any API endpoints that can't be used with an organization API token include a note like the following: -> \*\*Note:\*\* This endpoint cannot be accessed with [organization tokens](#organization-api-tokens). You must access it with a [user token](/terraform/cloud-docs/users-teams-organizations/users#api-tokens) or [team token](#team-api-tokens). ## Audit trail tokens You can generate an audit trails token to read an organization's [audit trails](/terraform/cloud-docs/api-docs/audit-trails). Use this token type to authenticate integrations pulling audit trail data, for example, using the [HCP Terraform for Splunk](/terraform/cloud-docs/integrations/splunk) app. To manage an organization's audit trails token, go to \*\*Organization settings > API Token\*\* and use the settings under the "Audit Token" header. Each organization can only have a \_single\_ valid audit trails token. Only [organization owners](/terraform/cloud-docs/users-teams-organizations/teams#the-owners-team) can generate or revoke an | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/api-tokens.mdx | main | terraform | [
0.0024287293199449778,
-0.000046195786126190796,
-0.026332881301641464,
-0.04722187668085098,
-0.008919409476220608,
-0.04546600207686424,
-0.011587780900299549,
-0.050150077790021896,
0.04552479460835457,
0.028372399508953094,
-0.020283859223127365,
-0.08062925189733505,
0.02223911136388778... | 0.095396 |
example, using the [HCP Terraform for Splunk](/terraform/cloud-docs/integrations/splunk) app. To manage an organization's audit trails token, go to \*\*Organization settings > API Token\*\* and use the settings under the "Audit Token" header. Each organization can only have a \_single\_ valid audit trails token. Only [organization owners](/terraform/cloud-docs/users-teams-organizations/teams#the-owners-team) can generate or revoke an organization's audit trails token. [permissions-citation]: #intentionally-unused---keep-for-maintainers ## Agent API Tokens [Agent pools](/terraform/cloud-docs/agents) have their own set of API tokens which allow agents to communicate with HCP Terraform, scoped to an organization. These tokens are not valid for direct usage in the HCP Terraform API and are only used by agents. ## Access Levels The following chart illustrates the various access levels for the supported API token types. Some permissions are implicit based on the token type, others are dependent on the permissions of the associated user, team, or organization. π΅ = Implicit for token type πΆ = Requires explicit permission | | User tokens | Team tokens | Organization tokens | | ---------------------------------- | :---------: | :---------: | :-----------------: | | \*\*Users\*\* | | | | | Manage account settings | π΅ | | | | Manage user tokens | π΅ | | | | \*\*Workspaces\*\* | | | | | Read workspace variables | πΆ | πΆ | π΅ | | Write workspace variables | πΆ | πΆ | π΅ | | Plan, apply, upload states | πΆ | πΆ | | | Force cancel runs | πΆ | πΆ | | | Create configuration versions | πΆ | πΆ | | | Create or modify workspaces | πΆ | πΆ | π΅ | | Remote operations | πΆ | πΆ | | | Manage run triggers | πΆ | πΆ | π΅ | | Manage notification configurations | πΆ | πΆ | | | Manage run tasks | πΆ | πΆ | π΅ | | \*\*Teams\*\* | | | | | Create teams | πΆ | πΆ | π΅ | | Modify team | πΆ | πΆ | π΅ | | Read team | πΆ | πΆ | π΅ | | Manage team tokens | πΆ | πΆ | π΅ | | Manage team workspace access | πΆ | πΆ | π΅ | | Manage team membership | πΆ | πΆ | π΅ | | \*\*Organizations\*\* | | | | | Create organizations | π΅ | | | | Modify organizations | πΆ | | | | Manage organization tokens | πΆ | | | | View audit trails | | | π΅ | | Invite users to organization | πΆ | πΆ | π΅ | | \*\*Sentinel\*\* | | | | | Manage Sentinel policies | πΆ | πΆ | π΅ | | Manage policy sets | πΆ | πΆ | π΅ | | Override policy checks | πΆ | πΆ | | | \*\*Integrations\*\* | | | | | Manage VCS connections | πΆ | πΆ | π΅ | | Manage SSH keys | πΆ | πΆ | | | Manage run tasks | πΆ | πΆ | π΅ | | \*\*Modules\*\* | | | | | Manage Terraform modules | πΆ | π΅ (owners) | | ## Token Expiration You can create user, team, and organization tokens with an expiration date and time. Once the expiration time has passed, the token is no longer treated as valid and may not be used to authenticate to any API. Any API requests made with an expired token will fail. HashiCorp recommends setting an expiration on all new authentication tokens. Creating tokens with an expiration date helps reduce the risk of accidentally leaking valid tokens or forgetting to | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/api-tokens.mdx | main | terraform | [
-0.03556809574365616,
0.01869090273976326,
0.015650322660803795,
0.023825112730264664,
0.05319327488541603,
-0.007098193280398846,
0.010317474603652954,
-0.07881046086549759,
0.06281815469264984,
0.060113575309515,
-0.018973397091031075,
-0.05744374170899391,
0.032077427953481674,
0.041798... | 0.129655 |
as valid and may not be used to authenticate to any API. Any API requests made with an expired token will fail. HashiCorp recommends setting an expiration on all new authentication tokens. Creating tokens with an expiration date helps reduce the risk of accidentally leaking valid tokens or forgetting to delete tokens meant for a delegated use once their intended purpose is complete. You can not modify the expiration of a token once you have created it. The HCP Terraform UI displays tokens relative to the current user's timezone, but all tokens are passed and displayed in UTC in ISO 8601 format through the HCP Terraform API. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/api-tokens.mdx | main | terraform | [
-0.03213481605052948,
0.0192460548132658,
0.025609975680708885,
-0.03284834325313568,
-0.004646228160709143,
-0.010654715821146965,
-0.05911048501729965,
-0.04211510717868805,
0.0202960092574358,
0.03390616178512573,
0.0035670604556798935,
-0.0033744298852980137,
0.0144500732421875,
0.0171... | 0.041063 |
# Configure two-factor authentication This topic describes how to enable two-factor authentication (2FA) and require it to access HCP Terraform and Terraform Enterprise interfaces. @include 'eu/2fa.mdx' ## Overview Configuring 2FA protects user accounts and sensitive data. Complete the following steps to configure 2FA for your organization: 1. Each member of the organization must enable 2FA for their accounts. 1. The organization owner enables the organization setting to require 2FA to access HCP Terraform and Terraform Enterprise interfaces. Additional configuration steps may be necessary for members who log into HCP Terraform and Terraform Enterprise using their HashiCorp Cloud Platform (HCP) credentials. Complete the following steps to use 2FA in your organizations. ## Requirements You must be an organization owner to require users within your organization to use 2FA. You can configure 2FA on HCP Terraform or Terraform Enterprise configured for IPv4. The messaging service that sends 2FA messages does not support IPv6 addresses. [permissions-citation]: #intentionally-unused---keep-for-maintainers ## Enable 2FA on user accounts 1. Sign in to Terraform Enterprise. 1. Click the user icon in the upper right corner and choose \*\*Account Settings\*\* from the menu. 1. Click \*\*Two Factor Authentication\*\* in the sidebar and enable one of the following settings: - \*\*Application\*\* - \*\*SMS Only (Text Message)\*\*. Note that you cannot use SMS when operating Terraform Enterprise in an IPv6-only network. Refer to [Requirements](#requirements). 1. Enter an SMS-enabled phone number. A phone number is optional when you enable \*\*Application\*\*. 1. Click \*\*Enable 2FA\*\* and complete the instructions to finish the configuration. 1. If you enabled \*\*Application\*\*, Terraform prompts you to scan a QR code and provide an authentication code to enable your TOTP-compliant application. ## Enable 2FA on user accounts 1. Sign in to [HCP Terraform](https://app.terraform.io/). 1. Click the user icon in the upper right corner and choose \*\*Account Settings\*\* from the menu. 1. Click \*\*Two Factor Authentication\*\* in the sidebar. 1. Click \*\*Enable 2FA\*\* and complete the instructions to finish the configuration. 1. Terraform prompts you to scan a QR code and provide an authentication code to enable your TOTP-compliant application. After enabling 2FA, you can perform the following actions: - Click \*\*Reveal codes\*\* to view single-use backup codes. Store the codes in a safe location so that you can use them to log in if necessary. - Click \*\*Disable 2FA\*\* to disable 2FA. ## Log in with 2FA enabled After setting up two-factor authentication, you must enter the code from your TOTP-compliant application or from an SMS sent to your approved SMS-enabled phone number whenever you login. After setting up two-factor authentication, you must enter the code from your TOTP-compliant application whenever you login. If necessary, you can also use a backup code by clicking \*\*Use a recovery code\*\*. You can only use each backup code to log in one time. ## Require 2FA for all users All organization owners must enable 2FA before you can require it for the organization. 1. Sign in to [HCP Terraform](https://app.terraform.io/) or Terraform Enterprise. 1. Choose your organization and click \*\*Settings\*\*. 1. Click \*\*Authentication\*\* and click \*\*Require two-factor\*\*. ## Require 2FA for HashiCorp Cloud Platform users Some users in your organization may log into HCP Terraform using their HashiCorp Cloud Platform (HCP) credentials. Refer to [Log in with a HashiCorp Cloud Platform account](/terraform/cloud-docs/users-teams-organizations/users#log-in-with-a-hashicorp-cloud-platform-account) for additional information. The required configuration for each organization member that logs in with their HCP credentials depends on their linked HCP identity: - \*\*Email\*\*: Follow the instructions in the [HashiCorp Cloud MFA](/hcp/docs/hcp/iam/mfa) docs. - \*\*GitHub\*\*: Follow the instructions in the [Configuring GitHub two-factor authentication](https://docs.github.com/en/authentication/securing-your-account-with-two-factor-authentication-2fa/configuring-two-factor-authentication) docs. - \*\*SSO\*\*: HCP Terraform does not support HCP SSO accounts. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/2fa.mdx | main | terraform | [
0.019757011905312538,
0.009068261831998825,
0.008985595777630806,
-0.07328832894563675,
-0.02274610847234726,
0.020644791424274445,
-0.0359683595597744,
-0.04642346128821373,
-0.0551847405731678,
0.007943443022668362,
-0.022857224568724632,
-0.12207835912704468,
0.04859023168683052,
0.0003... | 0.032722 |
logs in with their HCP credentials depends on their linked HCP identity: - \*\*Email\*\*: Follow the instructions in the [HashiCorp Cloud MFA](/hcp/docs/hcp/iam/mfa) docs. - \*\*GitHub\*\*: Follow the instructions in the [Configuring GitHub two-factor authentication](https://docs.github.com/en/authentication/securing-your-account-with-two-factor-authentication-2fa/configuring-two-factor-authentication) docs. - \*\*SSO\*\*: HCP Terraform does not support HCP SSO accounts. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/2fa.mdx | main | terraform | [
0.009463424794375896,
0.020318273454904556,
-0.009627469815313816,
-0.05304765701293945,
0.02014458365738392,
0.03217315301299095,
-0.026825731620192528,
-0.021371904760599136,
-0.045397598296403885,
0.02255392074584961,
0.028482429683208466,
-0.10630730539560318,
0.056295908987522125,
-0.... | 0.025086 |
[organizations]: /terraform/cloud-docs/users-teams-organizations/organizations [teams]: /terraform/cloud-docs/users-teams-organizations/teams [invite]: /terraform/cloud-docs/users-teams-organizations/organizations#users [owners]: /terraform/cloud-docs/users-teams-organizations/teams#the-owners-team # Create and manage users User accounts belong to individual people. Each user can be part of one or more [teams](/terraform/cloud-docs/users-teams-organizations/teams), which are granted permissions on projects and projects and workspaces within an organization. A user can be a member of multiple [organizations][]. @include 'eu/group.mdx' ## API Use the [Account API](/terraform/cloud-docs/api-docs/account) to get account details, update account information, and change your password. ## Log in with a HashiCorp Cloud Platform account We recommend using a [HashiCorp Cloud Platform (HCP)](https://portal.cloud.hashicorp.com/sign-up) account to log in to HCP Terraform. Your HCP Account grants access to every HashiCorp product and the Terraform Registry. If you use an HCP Account, you manage account settings like multi-factor authentication and password resets from within HCP instead of the HCP Terraform UI. To log in with your HCP account, navigate to [HCP Terraform](https://app.terraform.io/) and login with your HCP credentials. ### Linking HCP and HCP Terraform accounts The first time you log in with your HCP credentials, HCP Terraform searches for an existing HCP Terraform account with the same email address. If you have an unlinked account, HCP Terraform asks if you want to link it to your HCP account. Otherwise, if no account matches your HCP account's email address, HCP Terraform creates and automatically links a new HCP Terraform account to your HCP account. > \*\*Note\*\*: You can only log in with your HCP credentials after linking your HCP and HCP Terraform accounts. We do not recommend linking your account if you use an SSO provider to log in to HCP Terraform because linking your account may conflict with your existing SSO configuration. The only way to log in with your old HCP Terraform credentials is to unlink your HCP Terraform and HCP accounts. If HCP Terraform generated an account for you, you cannot unlink that account from your HCP account. You can unlink a pre-existing HCP Terraform account on the [HCP Account Linking page](#hcp-account-linking) in your \*\*Account settings\*\*. ## Creating an account To use HCP Terraform or Enterprise, you must create an account through one of the following methods: - \*\*Invitation Email:\*\* When a user sends you an invitation to join an existing HCP Terraform organization, the email includes a sign-up link. After you create an account, you can automatically join that organization and can begin using HCP Terraform. - \*\*Sign-Up Page:\*\* Creating an account requires a username, an email address, and a password. [Sign up on HCP Terraform](https://app.terraform.io/public/signup/account) or if you have a Terraform Enterprise instance, go to `https:///public/signup/account`. After you create an account, you do not belong to any organizations. To begin using HCP Terraform, you can either [create an organization](/terraform/cloud-docs/users-teams-organizations/organizations#creating-organizations) or ask an organization owner to send you an invitation email to join their organization. We recommend logging into HCP Terraform [with your HCP account](#log-in-with-your-hashicorp-cloud-platform-account) instead of creating a separate HCP Terraform account. ## Joining organizations and teams An organization owner or a user with [\*\*Manage Membership\*\*](/terraform/cloud-docs/users-teams-organizations/permissions/organization#manage-membership) permissions enabled must [invite you to join their organization](/terraform/cloud-docs/users-teams-organizations/organizations#users) and [add you to one or more teams](/terraform/cloud-docs/users-teams-organizations/teams/manage#manage-team-membership). [permissions-citation]: #intentionally-unused---keep-for-maintainers HCP Terraform sends user invitations by email. If the invited email address matches an existing HCP Terraform account, the invitee can join the organization with that account. Otherwise, they must create a new account and then join the organization. ## Site admin permissions On Terraform Enterprise instances, some user accounts have a special site admin permission that allows them to administer the entire instance. Admin permissions are distinct from normal organization-level permissions, and they apply to a different set of UI controls and API endpoints. Admin users can administer any | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/users.mdx | main | terraform | [
-0.0086995093151927,
-0.0021579815074801445,
-0.032477006316185,
-0.05533722788095474,
-0.011335248127579689,
-0.04473491385579109,
-0.010431928560137749,
-0.04437633603811264,
0.04241305962204933,
0.03766501694917679,
-0.04049811512231827,
-0.07190614193677902,
0.08431947976350784,
0.0347... | 0.052976 |
Site admin permissions On Terraform Enterprise instances, some user accounts have a special site admin permission that allows them to administer the entire instance. Admin permissions are distinct from normal organization-level permissions, and they apply to a different set of UI controls and API endpoints. Admin users can administer any resource across the instance when using the site admin pages or the [admin API](/terraform/enterprise/api-docs/admin), but they have normal user permissions when using an organization's standard UI controls and API endpoints. These normal user permissions are determined by team membership. Refer to [Administering Terraform Enterprise](/terraform/enterprise/admin) for more details. ## Account settings To view your settings page, click your user icon and select \*\*Account settings\*\*. Your \*\*Profile\*\* page appears, showing your username, email address, and avatar. ### Profile Click \*\*Profile\*\* in the sidebar to view and edit the username and email address associated with your HCP Terraform account. ~> \*\*Important:\*\* HCP Terraform includes your username in URL paths to resources. If external systems make requests to these resources, you must update them before you change your username. HCP Terraform uses [Gravatar](http://en.gravatar.com) to display a user icon if you have associated one with your email address. Refer to the [Gravatar documentation](http://en.gravatar.com/support/) for details about changing your user icon. ### Sessions Click \*\*Sessions\*\* in the sidebar to view a list of sessions associated with your HCP Terraform account. You can revoke any sessions you do not recognize. There are two types of Terraform accounts, standalone HCP Terraform accounts and HCP Terraform accounts linked to HCP accounts. ### Idle session timeout HCP Terraform automatically terminates user sessions if there has been no end-user activity for a certain time period: - Standalone HCP Terraform accounts can stay idle and valid for up to 14 days by default - HCP Terraform accounts linked to an HCP account follow the HCP defaults and can stay idle for 1 hour by default After HCP Terraform terminates a session, you can resume it by logging back in through the HCP Terraform portal. This is a security measure to prevent unauthorized access to unmonitored devices. -> \*\*Note:\*\* HCP Terraform organization owners can reduce the idle session timeout for an organization in the authentication settings for standalone HCP Terraform accounts, but cannot modify settings for HCP Terraform accounts linked to HCP accounts. ### Forced re-authentication Forced re-authentication (e.g., βremember forβ) makes a user re-authenticate, regardless of activity. This is a security measure to force a new identity verification to access sensitive IT and data managed by HCP Terraform. In this case, the user must re-authenticate their credentials and may be asked to verify 2FA/MFA again. - By default, standalone HCP Terraform accounts are forced to re-authenticate every 14 days - By default, HCP Terraform accounts linked to an HCP account follow the HCP defaults and are forced to re-authenticate every 48 hours -> \*\*Note:\*\* HCP Terraform organization owners can reduce the idle session timeout for standalone HCP Terraform accounts, but cannot modify settings for HCP Terraform accounts linked to HCP accounts. ### Impact to user experience The default re-authentication defaults force users to re-authenticate at the beginning of each work week (Monday through Friday). Note that several actions immediately terminate active sessions, including: \* Manually logging out of the HCP or HCP Terraform portals \* Clearing browser session/cookies \* Closing all active browser windows Any of these actions requires you to re-authenticate regardless of session timeout settings. ### Organizations Click \*\*Organizations\*\* in the sidebar to view a list of the organizations where you are a member. If you are on the [owners team][owners], the organization is marked with an \*\*OWNER\*\* badge. To | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/users.mdx | main | terraform | [
0.011658781208097935,
0.006667421665042639,
-0.010730176232755184,
-0.020159471780061722,
-0.017370644956827164,
-0.05355583131313324,
-0.006418393459171057,
-0.046961959451436996,
0.008276929147541523,
0.09714999049901962,
-0.03657675161957741,
-0.036750491708517075,
0.003210707101970911,
... | 0.022891 |
browser windows Any of these actions requires you to re-authenticate regardless of session timeout settings. ### Organizations Click \*\*Organizations\*\* in the sidebar to view a list of the organizations where you are a member. If you are on the [owners team][owners], the organization is marked with an \*\*OWNER\*\* badge. To leave an organization, click the ellipses (\*\*...\*\*) next to the organization and select \*\*Leave organization\*\*. You do not need permission from the owners to leave an organization, but you cannot leave if you are the last member of the owners team. Either add a new owner and then leave, or [delete the organization](/terraform/cloud-docs/users-teams-organizations/organizations#general). ### Password Click \*\*Password\*\* in the sidebar to change your password. You cannot manage your HCP Terraform password directly if you linked your account to GitHub or HashiCorp Cloud Platform (HCP). Instead, manage your password through the linked service. Passwords must be at least eight characters long, and contain at least three of the following: \* Lowercase letters (a-z) \* Uppercase letters (A-Z) \* Numbers (0-9) \* Special characters (!@#$%^&\*) Password management is not available if your Terraform Enterprise instance uses [SAML single sign on](/terraform/enterprise/saml/configuration). ### Two-factor authentication Click \*\*Two Factor Authentication\*\* in the sidebar to enable two-factor authentication. Two-factor authentication requires a TOTP-compliant application or an SMS-capable phone number. An organization can set policies that require two-factor authentication. Refer to [Two-Factor Authentication](/terraform/cloud-docs/users-teams-organizations/2fa) for details. ### HCP account linking Click \*\*HCP Account Linking\*\* in the sidebar to unlink your HCP Terraform from your HCP Account. You cannot unlink an account that HCP Terraform autogenerated during the linking process. Refer to [Linked HCP and HCP Terraform Accounts](#linked-hcp-and-hcp-terraform-accounts) for more details. After you unlink, you can begin using your HCP Terraform credentials to log in. You cannot log in with your HCP account again unless you re-link it to your HCP Terraform account. ### SSO identities Click \*\*SSO Identities\*\* in the sidebar to review and [remove SSO identity links](/terraform/cloud-docs/users-teams-organizations/single-sign-on/linking-user-account#remove-sso-identity-link) associated with your account. You have an SSO identity for every SSO-enabled HCP Terraform organization. HCP Terraform links each SSO identity to a single HCP Terraform user account. This link determines which account you can use to access each organization. ### Tokens Click \*\*Tokens\*\* in the sidebar to create, manage, and revoke API tokens. HCP Terraform has three kinds of API tokens: user, team, and organization. Users can be members of multiple organizations, so user tokens work with any organization where the associated user is a member. Refer to [API Tokens](/terraform/cloud-docs/users-teams-organizations/api-tokens) for details. API tokens are required for the following tasks: - Authenticating with the [HCP Terraform API](/terraform/cloud-docs/api-docs). API calls require an `Authorization: Bearer ` HTTP header. - Authenticating with the [HCP Terraform CLI integration](/terraform/cli/cloud/settings) or the [`remote` backend](/terraform/language/settings/backends/remote). These require a token in the CLI configuration file or in the backend configuration. - Using [private modules](/terraform/cloud-docs/registry/using) in command-line runs on local machines. This requires [a token in the CLI configuration file](/terraform/cloud-docs/registry/using#authentication). Protect your tokens carefully because they contain the same permissions as your user account. For example, if you belong to a team with permission to read and write variables for a workspace, another user could use your API token to authenticate as your user account and also edit variables in that workspace. Refer to [permissions](/terraform/cloud-docs/users-teams-organizations/permissions) for more details. We recommend protecting your tokens by creating them with an expiration date and time. Refer to [API Token Expiration](/terraform/cloud-docs/users-teams-organizations/api-tokens#token-expiration) for details. #### Creating a token To create a new token: 1. Click \*\*Create an API token\*\*. The \*\*Create API token\*\* box appears. 1. Enter a \*\*Description\*\* that explains what the token is for and click \*\*Create API token\*\*. 1. You | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/users.mdx | main | terraform | [
-0.029251964762806892,
0.03616726025938988,
-0.03556327521800995,
-0.021167591214179993,
0.008162525482475758,
0.04136836528778076,
0.007414449006319046,
-0.1115892082452774,
0.07381679862737656,
0.08328485488891602,
-0.05026036500930786,
-0.029255632311105728,
0.047912269830703735,
0.0279... | 0.00316 |
expiration date and time. Refer to [API Token Expiration](/terraform/cloud-docs/users-teams-organizations/api-tokens#token-expiration) for details. #### Creating a token To create a new token: 1. Click \*\*Create an API token\*\*. The \*\*Create API token\*\* box appears. 1. Enter a \*\*Description\*\* that explains what the token is for and click \*\*Create API token\*\*. 1. You can optionally enter the token's expiration date or time, or create a token that never expires. The UI displays a token's expiration date and time in your current time zone. 1. Copy your token from the box and save it in a secure location. HCP Terraform only displays the token once, right after you create it. If you lose it, you must revoke the old token and create a new one. [permissions-citation]: #intentionally-unused---keep-for-maintainers #### Revoking a token To revoke a token, click the \*\*trash can\*\* next to it. That token will no longer be able to authenticate as your user account. ~> \*\*Note\*\*: HCP Terraform does not revoke a user API token's access to an organization when you remove the user from an SSO Identity Provider as the user may still be a member of the organization. To remove access to a user's API token, remove the user from the organization in the UI or with the [Terraform Enterprise provider](https://registry.terraform.io/providers/hashicorp/tfe/latest). #### Tokens disabled User tokens can be disabled at the organization level, for more information refer to [User API tokens](/terraform/cloud-docs/users-teams-organizations/api-tokens#user-api-tokens). ### GitHub app OAuth token Click \*\*Tokens\*\* in the sidebar to manage your GitHub App token. This token lets you connect a workspaces to an available GitHub App installation. ~> \*\*Note:\*\* Only an HCP Terraform user can own a GitHub App token. Team and Organization API tokens are not able to own a GitHub App token. A GitHub App token lets you: - Connect workspaces, policy sets, and registry modules to a GitHub App installation with the [HCP Terraform API](/terraform/cloud-docs/api-docs) and UI. - View available GitHub App installations with the [HCP Terraform API](/terraform/cloud-docs/api-docs) and UI. After generating this token, you can use it to view information about your available installations for the Terraform Cloud GitHub App. #### Creating a GitHub app token To create a GitHub App token, click \*\*Create a GitHub App token\*\*. The \*\*GitHub App authorization pop-up window\*\* appears requesting authorization of the Terraform Cloud GitHub App. ~> \*\*Note:\*\* This does not grant HCP Terraform access to repositories. #### Revoking a GitHub app token To revoke the GitHub App token, click the \*\*ellipses button (...)\*\*. The dropdown menu appears. Click the \*\*Delete Token\*\* option. This triggers a confirmation window to appear, which asks you to confirm that you want to revoke the token. Once confirmed, the token is revoked and you can no longer view GitHub App installations. #### Additional resources - [GitHub App permissions in HCP Terraform](/terraform/cloud-docs/vcs/github-app#github-permissions) | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/users.mdx | main | terraform | [
-0.019531501457095146,
0.01952298916876316,
0.016658524051308632,
0.022902961820364,
0.01456946600228548,
0.013199114240705967,
-0.043200455605983734,
-0.03215926140546799,
0.08152272552251816,
0.07733640819787979,
-0.044910281896591187,
-0.05029410496354103,
0.0267555583268404,
-0.0062236... | 0.053101 |
# Create and manage reserved tag keys This topic describes how to create and manage reserved tag keys in HCP Terraform. You can use reserved tag keys to help managers consistently label workspaces and projects in your organization. ## Introduction You can define reserved tag keys that appear as suggested labels when managers want to add tags to their projects and workspaces in the organization. Doing so helps you standardize tag keys and prevent duplicates that affect your ability to track resources. Refer to the following topics for information about creating and managing tags attached to projects and workspaces: - [Create a project](/terraform/cloud-docs/projects/manage#create-a-project) - [Create workspace tags](/terraform/cloud-docs/workspaces/tags) ## Requirements The \*\*admin\*\* permission preset must be enabled on your profile to create and manage reserved tags. Refer to [Permissions](/terraform/cloud-docs/users-teams-organizations/permissions/organization) for additional information. ## Define a reserved tag key You can define reserved tag keys for your organization so that project and workspace managers can use consistent labels. 1. Sign in to [HCP Terraform](https://app.terraform.io/) or Terraform Enterprise and navigate to the organization you want to define a reserved tag for. 1. Choose \*\*Settings\*\* from the sidebar, then \*\*Tags\*\*. 1. Click on the \*\*Reserved Keys\*\* tab. 1. Click \*\*New reserved tag key\*\* and specify a key value when prompted. Keys are unique and can have up to 128 characters. You can use letters, numbers, spaces, and the following special characters: `.`, `=`, `+`, `-`, `@`, `:`, `-`, and `\_`. 1. You can enable the \*\*Disable overrides\*\* option to prevent project and workspace managers from overriding the key. Refer to [Disable overrides for project tags](#disable-overrides-for-project-tags) for additional information. 1. Click \*\*Save\*\* to finish adding the key. ## Delete a reserved key 1. Sign in to [HCP Terraform](https://app.terraform.io/) or Terraform Enterprise and navigate to the organization where you want to delete a reserved tag. 1. Choose \*\*Settings\*\* from the sidebar, then \*\*Tags\*\*. 1. Click on the \*\*Reserved Keys\*\* tab. 1. Open the ellipses menu and choose \*\*Delete \*\*. 1. Click \*\*Yes, delete reserved key\*\* when prompted. To re-add a key, you must manually complete the steps described in [Define a reserved tag key](#define-a-reserved-tag-key). ## Edit a reserved key 1. Sign in to [HCP Terraform](https://app.terraform.io/) or Terraform Enterprise and navigate to the organization where you want to edit a reserved tag. 1. Choose \*\*Settings\*\* from the sidebar, then \*\*Tags\*\*. 1. Click on the \*\*Reserved Keys\*\* tab. 1. Open the ellipses menu and choose \*\*Edit \*\*. 1. Specify your changes and click \*\*Save\*\*. ## Disable overrides for project tags Enable the \*\*Disable overrides\*\* option when creating or editing a reserved tag key to prevent project and workspace managers from overriding the tag keys. This option is not retroactive. When a workspace contains keys that were overridden before you enabled the \*\*Disable overrides\*\* option, you must first remove the tags from the workspace. You can then re-apply the keys to the workspace so that HCP Terraform can allow future updates to the workspace tag bindings. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/organizations/manage-reserved-tags.mdx | main | terraform | [
-0.02108924835920334,
0.01083921454846859,
-0.027930574491620064,
0.024676579982042313,
0.022263284772634506,
-0.020917270332574844,
0.018018774688243866,
-0.05948172137141228,
0.019622771069407463,
0.07567476481199265,
0.00400771526619792,
-0.10004395991563797,
0.07866527140140533,
0.0093... | 0.02636 |
[teams]: /terraform/cloud-docs/users-teams-organizations/teams [users]: /terraform/cloud-docs/users-teams-organizations/users [owners]: /terraform/cloud-docs/users-teams-organizations/teams#the-owners-team # Organizations overview This topic provides overview information about how to create and manage organizations in HCP Terraform and Terraform Enterprise. An organization contains one or more projects. @include 'eu/organization.mdx' ## Requirements You must have \*\*Admin\*\* level-permissions to manage organizations in the HCP Terraform UI. Refer to [Permissions](/terraform/cloud-docs/users-teams-organizations/permissions/organization#organization-owners) to learn more. ## API and Terraform Enterprise Provider In addition to the HCP Terraform UI, you can use the following methods to manage organizations: - [Organizations API](/terraform/cloud-docs/api-docs/organizations) - The `tfe` provider [`tfe\_organization`](https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/organization) resource ## Select an organization HCP Terraform displays your current organization in the sidebar. To select an organization: 1. Sign in to [HCP Terraform](https://app.terraform.io/) or Terraform Enterprise. 1. Click the current organization name to view a list of all the organizations where you are a member. 1. Click an organization to select it. HCP Terraform displays list of workspaces and Stacks within that organization. ## Join an organization @include 'eu/group.mdx' To join an organization, the organization [owners][] or a user with specific [team management](/terraform/cloud-docs/users-teams-organizations/permissions/organization#team-management-permissions) permissions must invite you, and you must accept the emailed invitation. [Learn more](#users). [permissions-citation]: #intentionally-unused---keep-for-maintainers ## Leave an organization [Contact HCP support](/hcp/docs/hcp/admin/support) to leave an HCP Europe organization. To learn more, refer to [Use HCP Terraform in Europe](/terraform/cloud-docs/europe). 1. Sign in to [HCP Terraform](https://app.terraform.io/) or Terraform Enterprise and click the Terraform logo in the page header to navigate to the \*\*Organizations\*\* page. 1. Open the \*\*...\*\* ellipses menu next to the organization and select \*\*Leave organization\*\*. You do not need permission from the owners to leave an organization, but you cannot leave if you are the last member of the owners team. Either add a new owner and then leave, or [delete the organization](/terraform/cloud-docs/users-teams-organizations/organizations#general). ## Create an organization @include 'eu/organization.mdx' On HCP Terraform, any user can create a new organization. If you do not belong to any organizations, HCP Terraform prompts you to create one the first time you [sign in](https://app.terraform.io/). To create an organization: 1. Click the current organization name and select \*\*Create new organization\*\*. The \*\*Create a new organization\*\* page appears. 1. Enter a unique \*\*Organization name\*\* Organization names can include numbers, letters, underscores (`\_`), and hyphens (`-`). 1. Provide an \*\*Email address\*\* to receive notifications about the organization. 1. Click \*\*Create organization\*\*. HCP Terraform shows the new organization and prompts you to create a new workspace. You can also [invite other users](#users) to join the organization. On Terraform Enterprise, administrators can restrict your ability to create organizations. Refer to [Organization Creation](/terraform/enterprise/admin/application/general#organization-creation) for details. ## Managed resources Your organizationβs managed resource count helps you understand the number of infrastructure resources that HCP Terraform manages across all your workspaces and Stacks. HCP Terraform reads all the workspace and Stack deployment state files to determine the total number of managed resources. Each [resource](/terraform/language/resources/syntax) instance in the state equals one managed resource. HCP Terraform includes resources in modules and each resource created with the `count` or `for\_each` meta-arguments. HCP Terraform does not include [data sources](/terraform/language/data-sources) in the count. Refer to [Managed Resources Count](/terraform/cloud-docs/workspaces/state#managed-resources-count) in the workspace state documentation for more details. You can view your organization's managed resource count on the \*\*Usage\*\* page. ## Create and manage reserved tag keys ~> \*\*Reserved tag keys are in beta\*\*: We do not recommend using beta features in production environments. You can define reserved tag keys that appear as suggested labels when managers want to add tags to their projects and workspaces in the organization. Refer to [Create and manage reserved tag keys](/terraform/cloud-docs/users-teams-organizations/organizations/manage-reserved-tags) for instructions. You can also view single-value tags that may already be attached to projects and workspaces. Refer to [Tags](#tags) | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/organizations/index.mdx | main | terraform | [
0.014451626688241959,
-0.008240215480327606,
-0.023126184940338135,
-0.04045700281858444,
-0.046979229897260666,
-0.021563082933425903,
-0.05253243073821068,
-0.06041599437594414,
-0.024404678493738174,
0.041820019483566284,
-0.051889851689338684,
-0.10705210268497467,
0.0528978556394577,
... | 0.088568 |
reserved tag keys that appear as suggested labels when managers want to add tags to their projects and workspaces in the organization. Refer to [Create and manage reserved tag keys](/terraform/cloud-docs/users-teams-organizations/organizations/manage-reserved-tags) for instructions. You can also view single-value tags that may already be attached to projects and workspaces. Refer to [Tags](#tags) in the organization settings reference for additional information. ## Managing settings @include 'eu/organization.mdx' To view and manage an organization's settings, click \*\*Settings\*\*. The contents of the organization settings depends on your permissions within the organization. All users can review the organization's contact email, view the membership of any teams they belong to, and view the organization's authentication policy. [Organization owners][owners] can view and manage the entire list of organization settings. Refer to [Organization Permissions](/terraform/cloud-docs/users-teams-organizations/permissions/organization) for details. You may be able to manage the following organization settings. [permissions-citation]: #intentionally-unused---keep-for-maintainers ### Organization settings #### General Review the organization name and contact email. Organization owners can choose to change the organization name, contact email, and the default execution mode, or delete the organization. When an organization owner updates the default execution mode, all workspaces configured to [inherit this value](/terraform/cloud-docs/workspaces/settings#execution-mode) will be affected. Organization owners can also choose whether [workspace administrators](/terraform/cloud-docs/users-teams-organizations/permissions/workspace#workspace-admin) can delete workspaces that are managing resources. Deleting a workspace with resources under management introduces risk because Terraform can no longer track or manage the infrastructure. The workspace's users must manually delete any remaining resources or [import](/terraform/cli/commands/import) them into another Terraform workspace. Organization owners using HCP Terraform Standard edition can choose whether members with [module management permissions](/terraform/cloud-docs/users-teams-organizations/permissions/organization#manage-private-registry) can [generate module tests](/terraform/cloud-docs/registry/test#generated-module-tests). ##### Renaming an organization !> \*\*Warning:\*\* Deleting or renaming an organization can be very disruptive. We strongly recommend against deleting or renaming organizations with active members. To rename an organization that manages infrastructure: 1. Alert all members of the organization about the name change. 1. Sign in to [HCP Terraform](https://app.terraform.io/) or Terraform Enterprise and navigate to the organization you want to rename. 1. Cancel in progress and pending runs or wait for them to finish. HCP Terraform cannot change the name of an organization with runs in progress. 1. Lock all workspaces to ensure that no new runs will start before you change the name. 1. Rename the organization. 1. Update all components using the HCP Terraform API to the new organization name. This includes Terraform's `cloud` block CLI integration, the `tfe` Terraform provider, and any external API integrations. 1. Unlock workspaces and resume normal operations. @include 'eu/organization.mdx' #### Plan & Billing @include 'eu/billing.mdx' Review the organization's plan and any invoices for previous plan payments. Organization owners can also upgrade to one of HCP Terraform's paid plans, downgrade to a free plan, or begin a free trial of paid features. #### Tags Click the \*\*Tags\*\* tab in the \*\*Tags Management\*\* screen to view single-value tags that may have already been created in your system. The table on lists the tags in the system, the number of times a tag appears in a project or workspace, and the date the tag was created. The only action you can perform in the UI is deleting single-value tags from the system. You can use the following methods to delete single-value tags: 1. Select one or more tags and click \*\*Delete tags\*\*. 1. Select the \*\*Name\*\* header to select all tags, then click \*\*Delete tags\*\*. 1. Click the trash icon for a tag and confirm that you want to permanently delete it when prompted. #### Teams @include 'tfc-package-callouts/team-management.mdx' All users in an organization can access the \*\*Teams\*\* page, which displays a list of [teams][] within the organization. Organization owners and users with the [include secret teams | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/organizations/index.mdx | main | terraform | [
-0.0024897248949855566,
0.029021287336945534,
-0.06432794779539108,
0.030027320608496666,
0.07825738191604614,
-0.035893019288778305,
0.027619067579507828,
-0.06964126974344254,
0.07130362093448639,
0.06457676738500595,
-0.00010809100785991177,
-0.0504772812128067,
0.04805305600166321,
0.0... | 0.05304 |
Click the trash icon for a tag and confirm that you want to permanently delete it when prompted. #### Teams @include 'tfc-package-callouts/team-management.mdx' All users in an organization can access the \*\*Teams\*\* page, which displays a list of [teams][] within the organization. Organization owners and users with the [include secret teams permission](/terraform/cloud-docs/users-teams-organizations/permissions/organization#include-secret-teams) can: \* view all [secret teams](/terraform/cloud-docs/users-teams-organizations/teams/manage#team-visibility) \* view each team's membership \* manage team API tokens HCP Terraform restricts team creation, team deletion, and management of team API tokens to organization owners and users with the [manage teams](/terraform/cloud-docs/users-teams-organizations/permissions/organization#manage-teams) permission. Organization owners and users with the [manage membership](/terraform/cloud-docs/users-teams-organizations/permissions/organization#manage-membership) permission can manage team membership. Remember that users must accept their organization invitations before you can add them to a team. @include 'eu/group.mdx' [permissions-citation]: #intentionally-unused---keep-for-maintainers #### Users Organization owners and users with [manage membership](/terraform/cloud-docs/users-teams-organizations/permissions/organization#manage-membership) permissions can invite HCP Terraform users into the organization, cancel invitations, and remove existing members. The list of users is separated into one tab for active users and one tab for invited users who have not yet accepted their invitations. For active users, the list includes usernames, email addresses, avatar icons, two-factor authentication status, and current team memberships. Use the \*\*Search by username or email\*\* field to filter these lists. User invitations are always sent by email; you cannot invite someone using their HCP Terraform username. To invite a user to an organization: 1. Click \*\*Invite a user\*\*. The \*\*invite a user\*\* box appears. 1. Enter the user's email address and optionally add them to one or more teams. If the user accepts the invitation, HCP Terraform automatically adds them to the specified teams. All permissions in HCP Terraform are managed through teams. Users can join an organization without belonging to any teams, but they cannot use HCP Terraform features until they belong to a team. Refer to [permissions](/terraform/cloud-docs/users-teams-organizations/permissions) for details. @include 'eu/group.mdx' [permissions-citation]: #intentionally-unused---keep-for-maintainers #### Variable Sets View all of the available variable sets and their variables. Users with [\*\*Manage variable set\*\* permissions](/terraform/cloud-docs/variables/managing-variables#variable-sets) can create variable sets and assign them to one or more projects or workspaces.Assigning a variable set to project gives lets your Stacks within that project access that variable set. Variable sets let you reuse the same variables across multiple workspaces or projects in an organization. For example, you could define a variable set of provider credentials and automatically apply it to several projects or workspaces, rather than manually defining credential variables in each. Changes to variable sets instantly apply to all appropriate workspaces, saving time and reducing errors from manual updates. Refer to the [variables overview](/terraform/cloud-docs/variables) documentation for details about variable types, scope, and precedence. Refer to [managing variables](/terraform/cloud-docs/variables/managing-variables) for details about how to create and manage variable sets. #### Health @include 'tfc-package-callouts/health-assessments.mdx' HCP Terraform can perform automatic health assessments in a workspace to assess whether its real infrastructure matches the requirements defined in its Terraform configuration. Health assessments include the following types of evaluations: - Drift detection determines whether your real-world infrastructure matches your Terraform configuration. Drift detection requires Terraform version 0.15.4+. - Continuous validation determines whether custom conditions in the workspaceβs configuration continue to pass after Terraform provisions the infrastructure. Continuous validation requires Terraform version 1.3.0+. You can enforce health assessments for all eligible workspaces or let each workspace opt in to health assessments through workspace settings. Refer to [Health](/terraform/cloud-docs/workspaces/health) in the workspaces documentation for more details. #### Runs From the Workspaces page, click \*\*Settings\*\* in the sidebar, then \*\*Runs\*\* to view all of the current runs in your organization's workspaces. The \*\*Runs\*\* page displays: - The name of the run - The run's ID - What triggered the run - | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/organizations/index.mdx | main | terraform | [
-0.029141584411263466,
0.03279147669672966,
-0.026695294305682182,
-0.020404113456606865,
0.07650488615036011,
-0.04963100701570511,
-0.0015596734592691064,
-0.11742331087589264,
0.08497822284698486,
0.05725087225437164,
-0.03951092064380646,
-0.03186310455203056,
0.06920143216848373,
0.02... | 0.040934 |
the workspaces documentation for more details. #### Runs From the Workspaces page, click \*\*Settings\*\* in the sidebar, then \*\*Runs\*\* to view all of the current runs in your organization's workspaces. The \*\*Runs\*\* page displays: - The name of the run - The run's ID - What triggered the run - The workspace and project where the run is taking place - When the latest change in the run occurred - A button allowing you to cancel that run You can apply the following filters to limit the runs HCP Terraform displays: - Click \*\*Needs Attention\*\* to display runs that require user input to continue, such as approving a plan or overriding a policy. - Click \*\*Running\*\* to display runs that are in progress. - Click \*\*On Hold\*\* to display paused runs. For precise filtering, click \*\*More filters\*\* and check the boxes to filter runs by specific [run statuses](/terraform/cloud-docs/workspaces/run/states), [run operations](/terraform/cloud-docs/workspaces/run/modes-and-options), workspaces, or [agent pools](/terraform/cloud-docs/agents/agent-pools). Click \*\*Apply filters\*\* to list the runs that match your criteria. You can dismiss any of your filtering criteria by clicking the \*\*X\*\* next to the filter name above the table displaying your runs. For more details about workspace run states, refer to [Run States and Stages](/terraform/cloud-docs/workspaces/run/states). To learn how to view Stack deployment runs, refer to [Review deployment runs](/terraform/cloud-docs/stacks/deploy/runs). ### Integrations #### Cost Estimation Enable and disable the [cost estimation](/terraform/cloud-docs/cost-estimation) feature for all workspaces. #### Policies @include 'tfc-package-callouts/policies.mdx' Policies let you define and enforce rules for runs in workspaces.Stacks do not support executing policies. You can write them using either the [Sentinel](/terraform/cloud-docs/policy-enforcement/define-policies/custom-sentinel) or [Open Policy Agent (OPA)](/terraform/cloud-docs/policy-enforcement/opa) policy-as-code frameworks and then group them into policy sets that you can apply to workspaces in your organization. To create policies and policy sets, you must have [permission to manage policies](/terraform/cloud-docs/users-teams-organizations/permissions#organization-permissions). #### Policy Sets @include 'tfc-package-callouts/policies.mdx' Create groups of policies and enforce those policy sets globally or on specific [projects](/terraform/cloud-docs/projects/manage) and workspaces.Stacks do not support executing policies. You can create policy sets through the Terraform API, by connecting a VCS repository containing policies, or directly in HCP Terraform. To create policies and policy sets, you must have [permission to manage policies](/terraform/cloud-docs/users-teams-organizations/permissions#organization-permissions). Refer to [Managing Policy Sets](/terraform/cloud-docs/policy-enforcement/manage-policy-sets) for details. [permissions-citation]: #intentionally-unused---keep-for-maintainers #### Run Tasks @include 'tfc-package-callouts/run-tasks.mdx' Manage the run tasks that you can add to workspaces within the organization. [Run tasks](/terraform/cloud-docs/workspaces/settings/run-tasks) let you integrate third-party tools and services at specific stages in the HCP Terraform run lifecycle. ### Security #### Agents @include 'tfc-package-callouts/agents.mdx' Create and manage [HCP Terraform agent pools](/terraform/cloud-docs/agents). HCP Terraform agents let HCP Terraform communicate with isolated, private, or on-premises infrastructure. This is useful for on-premises infrastructure types such as vSphere, Nutanix, OpenStack, enterprise networking providers, and infrastructure within a protected enclave. #### API Tokens Organization owners can set up a special [Organization API Token](/terraform/cloud-docs/users-teams-organizations/api-tokens) that is not associated with a specific user or team. #### Authentication @include 'eu/2fa.mdx' Organization owners can determine when users must reauthenticate and require [two-factor authentication](/terraform/cloud-docs/users-teams-organizations/2fa) for all members of the organization. #### SSH Keys Manage [SSH keys for cloning Git-based modules](/terraform/cloud-docs/workspaces/settings/ssh-keys) during workspace runs. This does not include keys to access a connected VCS provider. #### SSO @include 'eu/sso.mdx' Organization owners can set up an SSO provider for the organization. ### Version Control #### VCS General Configure [Automatically cancel plan-only runs triggered by outdated commits](/terraform/cloud-docs/users-teams-organizations/organizations/vcs-speculative-plan-management) to manage the setting. #### VCS Events -> \*\*Note:\*\* This feature is in beta. Review the event logs for GitLab.com connections. #### VCS Providers Configure [VCS providers](/terraform/cloud-docs/vcs) to use in the organization. You must have [permission to manage VCS settings](/terraform/cloud-docs/users-teams-organizations/permissions). [permissions-citation]: #intentionally-unused---keep-for-maintainers ### Destruction and Deletion #### Data Retention Policies Data retention policies are exclusive to | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/organizations/index.mdx | main | terraform | [
0.004457605537027121,
0.026991339400410652,
0.047361984848976135,
0.027566352859139442,
0.027901994064450264,
-0.009685548953711987,
-0.05050334334373474,
-0.14712436497211456,
0.014775301329791546,
0.08543746918439865,
-0.052986402064561844,
-0.02941368706524372,
0.006063202396035194,
-0.... | 0.021256 |
Events -> \*\*Note:\*\* This feature is in beta. Review the event logs for GitLab.com connections. #### VCS Providers Configure [VCS providers](/terraform/cloud-docs/vcs) to use in the organization. You must have [permission to manage VCS settings](/terraform/cloud-docs/users-teams-organizations/permissions). [permissions-citation]: #intentionally-unused---keep-for-maintainers ### Destruction and Deletion #### Data Retention Policies Data retention policies are exclusive to Terraform Enterprise, and not available in HCP Terraform. [Learn more about Terraform Enterprise](https://developer.hashicorp.com/terraform/enterprise). An organization owner can set or override the following data retention policies: - \*\*Admin default policy\*\* - \*\*Do not auto-delete\*\* - \*\*Auto-delete data\*\* Setting the data retention policy to \*\*Admin default policy\*\* disables the other data retention policy settings. By default, the \*\*Do not auto-delete\*\* option is enabled for an organization. This option directs Terraform Enterprise to retain data associated with configuration and state versions, but organization owners can define configurable data retention policies that allow Terraform to \_soft delete\_ the backing data associated with configuration versions and state versions. Soft deleting refers to marking a data object for garbage collection so that Terraform can delete the object after a set number of days. Once an object is soft deleted, any attempts to read the object will fail. Until the garbage collection process begins, you can restore soft deleted objects using the APIs described in the [configuration version documentation](/terraform/enterprise/api-docs/configuration-versions) and the [state version documentation](/terraform/enterprise/api-docs/state-versions). Terraform permanently deletes the archivist storage after the garbage collection grace period elapses. The organization policy is the default policy applied to all workspaces, but members of individual workspaces can set overriding policies for their workspaces that take precedence over the organization policy. ## Trial Expired Organizations HCP Terraform paid features are available as a free trial. When a free trial has expired, the organization displays a banner reading \*\*TRIAL EXPIRED β Upgrade Required\*\*. Organizations with expired trials return to the feature set of a free organization, but they retain any data created as part of paid features. Specifically, HCP Terraform disables the following features: - Teams other than `owners` and locks users who do not belong to the `owners` team out of the organization. HCP Terraform preserves team membership and permissions and re-enables them after you upgrade the organization. - Sentinel policy checks. HCP Terraform preserves existing policies and policy sets and re-enables them after you upgrade the organization. - Cost estimation. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/organizations/index.mdx | main | terraform | [
-0.01589270308613777,
0.03433073312044144,
0.036678921431303024,
0.014430810697376728,
-0.00838441401720047,
-0.01175394095480442,
0.00899141188710928,
-0.11679844558238983,
0.08289970457553864,
0.07829838991165161,
0.0011507063172757626,
-0.05569684877991676,
0.043494462966918945,
-0.0129... | 0.066215 |
# Configure VCS status checks Status checks are notifications sent to your version control system's VCS provider, providing details about specific commits, including the present status of the HCP Terraform run. Please refer to your VCS provider's documentation regarding status checks (e.g., [GitHub Status Checks](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/about-status-checks)). ## Permissions To modify VCS Status Checks settings, you must have [\*\*Manage VCS Settings\*\*](/terraform/cloud-docs/users-teams-organizations/permissions/organization#manage-vcs-settings) permissions. ## Managing organization VCS status check settings Organization owners can choose between \_aggregated\_ (default) and \_non-aggregated\_ status checks. This setting determines whether detailed information and links are accessed directly from the VCS provider or HCP Terraform. This setting also determines the number of status checks directly sent to the VCS Provider in response to actions such as pull or merge requests. To view and manage an organizationβs VCS Status Check settings, click \*\*Settings\*\* then \*\*Version Control\*\*. ### Aggregated status checks Aggregated status checks offer a streamlined experience if you have a single repository containing configuration for many workspaces (a.k.a., a monorepo). When aggregated status checks are enabled, HCP Terraform sends one VCS status check for all runs triggered by a VCS event. If multiple workspaces rely on a shared repository, HCP Terraform aggregates the status checks for these workspaces into one summary. This summary is unique to the workspace's organization and VCS client connection. You can access additional information about an aggregated status check in HCP Terraform by clicking the \*\*Details\*\* link a status check provides. This link directs you to an HCP Terraform page that offers the consolidated status check results across multiple workspaces, highlighting details such as resource changes and issues that require attention.  ### Non-aggregated status checks Non-aggregated status checks send your VCS provider a status check for each triggered workspace and related run stage in response to a VCS event. For example, a VCS push triggers checks for each related workspace's run stages, including the plan operation, policy checks, cost estimation, run tasks, and more. If you have a manageable amount of workspaces and want to visualize status checks on your VCS Provider rather than in HCP Terraform, use non-aggregated status checks.  #### Send passing commit statuses -> \*\*Note:\*\* Organization owners can only enable the \*\*Send passing commit statuses\*\* setting if the \*\*Aggregated status checks\*\* setting is disabled. Workspaces that use part of a shared repository do not typically run plans for changes that do not affect their files. This includes [speculative plans](/terraform/cloud-docs/workspaces/run/remote-operations#speculative-plans) on pull requests. Since \*\*pending\*\* VCS status checks can block pull requests, workspaces automatically send passing commit statuses for any PRs that do not affect their files. You can disable this behavior if it creates too many status checks for your VCS provider. You may want to do this if you have a large number of workspaces sharing one VCS repository. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/organizations/vcs-status-checks.mdx | main | terraform | [
0.01655745692551136,
0.010046718642115593,
0.024165954440832138,
-0.024618515744805336,
0.002419411903247237,
-0.01455574668943882,
-0.0452444888651371,
-0.0864638239145279,
0.024965524673461914,
0.11153703927993774,
-0.04553760215640068,
-0.06760043650865555,
0.007777427788823843,
-0.0420... | 0.004075 |
# Automatically cancel plan-only workspace runs This topic describes how to configure HCP Terraform to automatically cancel plan-only workspace runs triggered by pull requests in the VCS. ## Introduction When connected to a VCS, HCP Terraform can automatically start a workspace run that performs a `terraform plan` operation when someone creates a pull request (PR) in the repository. Refer to [Connecting to VCS](/terraform/cloud-docs/vcs) for additional information. When team members push new commits to the same branch, HCP Terraform starts new run that performs a `terraform plan` operation. But as team members push new commits, the queue of Terraform runs can cause delays and reduce efficiency. You can enable the \*\*Automatically cancel speculative plans for outdated commits\*\* option in the organization's settings screen so that HCP Terraform automatically cancel unfinished plan-only runs in VCS workflows. ## Configure automatic cancellation 1. Sign in to [HCP Terraform](https://app.terraform.io/) or Terraform Enterprise and select your organization. 1. Choose \*\*Settings\*\* from the sidebar. 1. Under the \*\*Version Control\*\* group of settings, click \*\*General\*\*. 1. Enable the \*\*Automatically cancel speculative plans for outdated commits\*\* option under the \*\*Manage speculative plans\*\* section. 1. Click \*\*Update settings\*\*. After enabling the option, HCP Terraform cancels ongoing or pending speculative plans when new commits are received on the same branch. ## Automated cancellation notifications When the \*\*Automatically cancel speculative plans for outdated commits\*\* option is enabled, HCP Terraform notifies you about plan-only workspace runs that are canceled as a result of the setting. Notifications appear in the following screens: - \*\*Run details page\*\*. Refer to [Viewing and managing workspace runs](/terraform/cloud-docs/workspaces/run/manage) for additional information. - \*\*VCS status checks\*\*. When the \*\*Non-aggregated status checks\*\* option is enabled in the version control settings, the notification explicitly states when a plan has been canceled automatically. When the \*\*Aggregated status checks\*\* option is enabled, HCP Terraform includes canceled plans in the result and identifies them separately from manually canceled plans. Refer to [VCS Status Checks](/terraform/cloud-docs/users-teams-organizations/organizations/vcs-status-checks) for additional information. - \*\*Aggregated status page\*\*. HCP Terraform prints the cancellation message in the aggregated status page in the \*\*Resources to be changed\*\* section. The section may not reflect a complete result if all runs associated with the commit reach completion. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/organizations/vcs-speculative-plan-management.mdx | main | terraform | [
-0.01235197577625513,
0.02628384530544281,
0.06534148007631302,
0.022491401061415672,
-0.014221208170056343,
-0.03167308121919632,
-0.05467411130666733,
-0.11290397495031357,
0.0692315399646759,
0.08666910231113434,
-0.033385563641786575,
-0.021157555282115936,
-0.006068558897823095,
-0.02... | 0.019448 |
# Namespace overview Namespaces let you connect a GitHub account to an HCP Terraform organization, letting organization members collectively manage that GitHub accountβs public registry artifacts. Every artifact in the [public Terraform registry](https://registry.terraform.io/) connects to a namespace that matches the name of the GitHub account that published that artifact. For example, the `iam` [provider](https://registry.terraform.io/modules/terraform-aws-modules/iam/aws/latest) is published by the `terraform-aws-modules` [namespace](https://registry.terraform.io/namespaces/terraform-aws-modules), which corresponds to an [Github organization](https://docs.github.com/en/organizations/collaborating-with-groups-in-organizations/about-organizations) account with the same name. You can claim a namespace in HCP Terraform by linking a GitHub account to an organization, claiming that accountβs namespace. Each GitHub account namespace can belong to one HCP Terraform organization. @include 'eu/public-namespace.mdx' ## The public and private registries The [Terraform registry](https://registry.terraform.io/) is a public interactive resource for discovering integrations and configuration packages. Anyone can publish and consume the artifacts in the public registry. An organization in HCP Terraform has a [private registry](/terraform/cloud-docs/registry) that allows members to share modules and providers privately with other members of their organization. An organization's private registry is separate from its public registry artifacts and workflows. For example, an organization owner can publish a new module to the public registry from one of their organization's claimed namespaces, and that module is not automatically included in that organization's private registry. If an organization member wants to use the newly published module, they must follow the the usual steps to [add that module to their private registry](/terraform/cloud-docs/registry/add). ## Manage namespaces and registry artifacts Namespaces do not support publishing or managing [policy libraries](/terraform/registry/policy-libraries/publishing) in the public registry. To publish or manage policy libraries with a namespace, continue to use the [existing registry workflows](/terraform/registry/policy-libraries/publishing#publishing-to-the-registry). Linking a GitHub account to an HCP Terraform organization lets organization members collectively manage the linked GitHub accountβs [public registry artifacts](/terraform/cloud-docs/public-namespace/artifacts) and the namespace itself. Organization owners can manage claimed namespaces and specify which team members can interact with an organization's namespaces by setting [organization-level permissions](/terraform/cloud-docs/users-teams-organizations/permissions/organization#manage-public-registry) to either \*\*Manage public modules\*\* or \*\*Manage public providers\*\*. Organization owners and teams with \*\*Manage public modules\*\* and \*\*Manage public providers\*\* permissions can perform the following actions for every namespaces in their organization: \* [Publish new providers or modules](/terraform/cloud-docs/public-namespace/artifacts#publish-artifacts) to the public registry under a namespace \* [Publish new versions](/terraform/cloud-docs/public-namespace/artifacts#publish-new-artifact-versions) of existing public registry artifacts \* [Add GPG keys](/terraform/cloud-docs/public-namespace/manage#manage-gpg-keys) to a namespace \* [Resync](/terraform/cloud-docs/public-namespace/artifacts#resync-artifacts) a namespaceβs public registry artifacts \* [View usage metrics](/terraform/cloud-docs/public-namespace/artifacts#view-artifacts) for public registry artifacts \* [Delete an artifact or an artifact version](/terraform/cloud-docs/public-namespace/artifacts#delete-artifacts-or-artifact-versions) | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/organizations/public-namespace/index.mdx | main | terraform | [
-0.06435073167085648,
-0.08383336663246155,
-0.050842974334955215,
0.022019527852535248,
-0.024244852364063263,
-0.046036284416913986,
0.011041299439966679,
-0.09836145490407944,
0.05804486945271492,
0.0151600930839777,
0.010275200009346008,
-0.09683024883270264,
0.10778480768203735,
0.006... | 0.091234 |
# Manage namespace artifacts Namespaces let you connect a GitHub account to an HCP Terraform organization, letting organization members collectively manage that GitHub accountβs existing and future public registry artifacts. Namespaces do not support publishing or managing [policy libraries](/terraform/registry/policy-libraries/publishing) in the public registry. To publish or manage policy libraries with a namespace, continue to use the [existing registry workflows](/terraform/registry/policy-libraries/publishing#publishing-to-the-registry). ## Requirements @include 'eu/public-namespace.mdx' The following permissions are necessary to manage a namespace's artifacts: - Organization owners or members with [\*\*Manage public modules\*\* permissions](/terraform/cloud-docs/users-teams-organizations/permissions/organization#manage-public-registry) can manage modules in the public registry - Organization owners or members with [\*\*Manage public providers\*\* permissions](/terraform/cloud-docs/users-teams-organizations/permissions/organization#manage-public-registry) can manage providers in the public registry ## Publish artifacts You can publish new modules and providers to the public registry under your organizationβs claimed namespace. The following workflow should be familiar to existing public registry users: 1. Set up a GitHub repository following the conventions and instructions outlined for the type of artifact you want to publish. - For [modules](/terraform/registry/modules/publish), ensure your repository meets the [requirements](/terraform/registry/modules/publish#requirements). - For [providers](/terraform/registry/providers/publishing), follow all of the steps up to the [Publishing to the Registry](/terraform/registry/providers/publishing#publishing-to-the-registry) section. - If you have not installed the [Terraform Cloud GitHub App](/terraform/cloud-docs/vcs/github-app) globally in your GitHub account, install the app in the repository you want to publish. 1. Sign in to [HCP Terraform](https://app.terraform.io/) and navigate to your organization, then select \*\*Registry\*\* in the sidebar, then \*\*Public namespaces\*\* and select the namespace you want to publish from. 1. Click \*\*Publish\*\* and select the type of artifact, provider or module, you want to publish. 1. Select the repository you want to publish. 1. If you are publishing a provider, choose a \*\*Category.\*\* 1. Check the box to agree to the terms of service. 1. Click \*\*Publish provider\*\* or \*\*Publish module.\*\* HCP Terraform then displays a list of all the versions of your provider or module currently in your repository, and the status of each version that the public registry creates. If you navigate away from this page before processing is complete, it continues in the background. ## Publish new artifact versions You can create new versions of public registry artifacts using the same workflow as individual GitHub accounts. Add a properly formatted tag for modules, or release for providers, to your artifact's GitHub repository. GitHub notifies HCP Terraform that a new version or release is available and instructs the public registry to create a new version. Once the public registry creates the new version it appears in your namespace in HCP Terraform. You can view artifact versions by clicking the ellipsis \*\*β¦\*\* next to an artifact and selecting \*\*View version history\*\*. New versions are also visible on your artifact's page in the public registry. If the new version creates errors, a notification appears on your organization's \*\*Public namespaces\*\* page. The notification includes an error, and after you fix the problem we recommend [creating a new tag or release](/terraform/registry/faq#how-do-i-correct-bugs-in-published-versions). ## View artifacts On the \*\*Public namespaces\*\* page, you can click the ellipsis \*\*β¦\*\* next to an artifact to list the available actions you can take on that artifact: - \*\*View in public registry\*\* links to the artifactβs page on [`https://registry.terraform.io`](https://registry.terraform.io). - \*\*View download data\*\* has the download metrics for the selected artifact. - View the number of times users have downloaded multiple versions, or select a single version to view the number of times users have downloaded it. - You can also download a CSV file that summarizes the monthly downloads of each artifact version. - \*\*View version history\*\* lists the artifact's published versions. - \*\*Add to private library\*\* adds the artifact to your organizationβs [private registry](/terraform/cloud-docs/registry). ## Delete artifacts or | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/organizations/public-namespace/artifacts.mdx | main | terraform | [
-0.02283305488526821,
-0.043208517134189606,
-0.05051574483513832,
-0.042440224438905716,
-0.018599500879645348,
-0.03176881745457649,
-0.029827795922756195,
-0.09087855368852615,
0.012138460762798786,
0.09391245245933533,
-0.038989510387182236,
-0.059234973043203354,
0.07788567245006561,
... | 0.047157 |
number of times users have downloaded it. - You can also download a CSV file that summarizes the monthly downloads of each artifact version. - \*\*View version history\*\* lists the artifact's published versions. - \*\*Add to private library\*\* adds the artifact to your organizationβs [private registry](/terraform/cloud-docs/registry). ## Delete artifacts or artifact versions On the \*\*Public namespaces\*\* page, you can delete modules, providers, and module and provider versions if you have the [correct permissions](#requirements) and an artifact meets specific deletion requirements. ### Deletion requirements To delete a provider, module, or a provider or module version, one of the following must be true: - Someone published the artifact less than 48 hours ago. - No version of the artifact was downloaded by users more than 100 times. ### Delete a provider If your provider meets [the deletion requirements](#deletion-requirements), you delete it by doing the following: - Clicking on the ellipsis \*\*β¦\*\* next to the artifact and choosing \*\*Delete provider\*\*. - Confirm by entering `delete` and click \*\*Delete provider\*\*. ### Delete a provider version If your provider meets [the deletion requirements](#deletion-requirements), you delete a version by doing the following: - Clicking on the ellipsis \*\*β¦\*\* next to the artifact and choosing to \*\*Delete version\*\*. - Entering the exact version of the provider to delete. - Confirm by entering `delete` and click \*\*Delete version\*\*. ### Delete a module If your module meets [the deletion requirements](#deletion-requirements), you delete it by doing the following: - Clicking on the ellipsis \*\*β¦\*\* next to the artifact and choosing \*\*Delete module.\*\* - Confirm by entering `delete` and click \*\*Delete module\*\*. ### Delete a module version If your module meets [the deletion requirements](#deletion-requirements), you delete a version by doing the following: - Clicking on the ellipsis \*\*β¦\*\* next to the artifact and choosing to \*\*Delete module version\*\*. - Entering the exact version of the module to delete. - Confirm by entering `delete` and click \*\*Delete module version\*\*. ## Resync artifacts Resyncing an artifact checks for discrepancies between the versions of an artifact on GitHub and the versions available within the public registry. Resyncing attempts to reconcile any differences by changing versions available in the public registry to match GitHub. If an artifact version exists in GitHub but not in the registry, HCP Terraform attempts to create new versions in the registry. If an artifact version exists in the registry but not in GitHub, HCP Terraform deletes the registry versions that [meet the deletion requirements](#deletion-requirements). To resync an artifact: 1. Click the ellipsis \*\*β¦\*\* next to the artifact you want to resync. 1. Select \*\*Resync\*\*. 1. HCP Terraform lists the versions it intends to create or delete, click \*\*Resync\*\* to confirm. You can then see the public registry's progress as it performs each operation. If you navigate away from this page before processing is complete it continues in the background | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/organizations/public-namespace/artifacts.mdx | main | terraform | [
-0.031064117327332497,
0.044365402311086655,
0.040711164474487305,
-0.028750739991664886,
0.05652215704321861,
-0.04663741588592529,
-0.02309298701584339,
-0.11986164003610611,
0.06084999814629555,
0.088130883872509,
0.00926363468170166,
-0.01741969771683216,
0.035131171345710754,
-0.02633... | 0.028779 |
# Manage namespaces After an HCP Terraform organization claims a namespace, you can configure that namespaceβs GPG keys or release your organization's claim on the namespace. @include 'eu/public-namespace.mdx' ## Requirements The following permissions are necessary to manage a namespace: - Organization owners or members with [\*\*Manage public providers\*\* permissions](/terraform/cloud-docs/users-teams-organizations/permissions/organization#manage-public-registry) can add or remove GPG keys. - Organization [owners](/terraform/cloud-docs/users-teams-organizations/permissions/organization#organization-owners) can release an organizationβs claim on a namespace. ## Manage GPG keys A namespace uses its GPG keys to [sign releases for a namespaceβs providers](/terraform/registry/providers/publishing#preparing-and-adding-a-signing-key). A namespaceβs settings page lists its current GPG keys. To add a new GPG key to the namespace: 1. Sign in to [HCP Terraform](https://app.terraform.io/) and navigate to your organization, then select \*\*Registry\*\* in the sidebar, then \*\*Public namespaces\*\*. 1. Choose the namespace you want to manage from the dropdown list and click \*\*Settings\*\* in the upper-right corner. 1. Click \*\*New GPG Key\*\*, which only appears to those with [\*\*Manage public providers\*\* permissions](/terraform/cloud-docs/users-teams-organizations/permissions/organization#manage-public-registry). 1. Paste the ASCII-armored text for your public GPG key in the modal window, including both `-----BEGIN PGP PUBLIC KEY BLOCK-----` and `-----END PGP PUBLIC KEY BLOCK-----`. 1. Click \*\*Add GPG Key\*\*. If successful, HCP Terraform lists your new key in your namespace's list of GPG keys. ## Release namespace claim A namespace can only have one owner. If you want to move a namespace from one organization to another, you must first release your ownership claim before reclaiming that namespace in another organization. To release a namespace claim: 1. Sign in to [HCP Terraform](https://app.terraform.io/) and navigate to your organization, then select \*\*Registry\*\* in the sidebar, then \*\*Public namespaces\*\*. 1. Choose the namespace you want to release from the dropdown list and click \*\*Settings\*\* in the upper-right corner. 1. Click \*\*Release\*\* under the \*\*Release claim\*\* section. 1. Confirm by typing the word "release" and then click \*\*Release\*\*. After releasing ownership of a namespace, you can [claim that namespace](/terraform/cloud-docs/public-namespace/create\_or\_claim) under another organization. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/organizations/public-namespace/manage.mdx | main | terraform | [
-0.04481339082121849,
-0.02010338380932808,
-0.00822481606155634,
0.010483085177838802,
-0.0064116716384887695,
-0.026921221986413002,
0.037885844707489014,
-0.10987632721662521,
0.03040088154375553,
0.09630399942398071,
-0.008609015494585037,
-0.06089096888899803,
0.05676776543259621,
0.0... | 0.026735 |
# Create or claim a namespace Organizations can create or claim a GitHub accountβs public registry namespace to allow its members to manage the public registry artifacts in that account. When an organization claims a namespace, the only way to manage that claimed namespace is through HCP Terraform, meaning you can no longer manage that namespace through the [public registry](https://registry.terraform.io/). Namespaces do not support publishing or managing [policy libraries](/terraform/registry/policy-libraries/publishing) in the public registry. To publish or manage policy libraries, continue to use the [existing registry workflows](/terraform/registry/policy-libraries/publishing#publishing-to-the-registry). ## Requirements @include 'eu/public-namespace.mdx' You must meet the following requirements to claim a namespace for an organization: \* Be a member of the [owners](/terraform/cloud-docs/users-teams-organizations/permissions/organization#organization-owners) team in your HCP Terraform organization. \* If the namespace you want to claim has existing public registry artifacts, you must: \* Have `write` access to each artifactβs corresponding repository. \* Each repository must have the [Terraform Cloud GitHub App](/terraform/cloud-docs/vcs/github-app) installed. ### Install the GitHub App You must install the [Terraform Cloud GitHub App](/terraform/cloud-docs/vcs/github-app) into the GitHub account with the namespace you want to claim. To install a GitHub app, you must own your account or receive administrator approval for your [organization](https://docs.github.com/en/organizations/collaborating-with-groups-in-organizations/about-organizations#organizations-and-enterprise-accounts) account. During the Terraform Cloud GitHub App installation process, you can choose to install the app in specific repositories or globally in every repository in your account. We recommend installing the Terraform Cloud GitHub App globally into every repository in your account to simplify claiming a namespace with existing public registry artifacts and publishing future artifacts. ## Workflow To create or claim a namespace: 1. Sign in to [HCP Terraform](https://app.terraform.io/) and navigate to the organization where you want to create or claim a namespace. 1. In the sidebar navigate to \*\*Registry\*\*, then \*\*Public namespaces\*\*. 1. Click \*\*New Namespace\*\*. 1. HCP Terraform lists accounts where you installed the [Terraform Cloud GitHub App](/terraform/cloud-docs/vcs/github-app). Choose the account you want to create or claim the namespace of. 1. After selecting an account, HCP Terraform verifies if you qualify to claim that namespace. - If the namespace already exists and contains artifacts, then HCP Terraform ensures you have `write` access to each artifactβs corresponding repository. 1. Click \*\*Create Namespace\*\* or \*\*Claim Namespace\*\* to finalize your organizationβs public namespace ownership. After claiming or creating a new namespace, the \*\*Public namespace\*\* page lists any artifacts your organization now controls under that namespace. If HCP Terraform does not list the GitHub account you want to claim on the \*\*New namespace\*\* page, click \*\*Add GitHub Account\*\* and follow the prompts to [reinstall the application](https://docs.github.com/en/apps/using-github-apps/installing-a-github-app-from-a-third-party). After reinstalling, sign into GitHub as a user with access to the account you want to claim and try again. For more information on any specific error codes you encounter, [refer to the GitHub documentation](https://docs.github.com/en/organizations/managing-user-access-to-your-organizations-repositories/managing-repository-roles/repository-roles-for-an-organization#repository-roles-for-organizations). | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/organizations/public-namespace/create_or_claim.mdx | main | terraform | [
-0.03654632344841957,
-0.0819450318813324,
-0.04130258783698082,
-0.02271953970193863,
-0.015311921015381813,
-0.029551248997449875,
-0.018420515581965446,
-0.08551522344350815,
0.027064083144068718,
0.08912667632102966,
-0.03481164947152138,
-0.09427602589130402,
0.08503857254981995,
0.01... | 0.022286 |
# Permissions overview To control access within organizations, add users to a \*\*team\*\* and grant the team permissions to perform actions, such as creating or updating one or more projects or workspaces. If you are in a HashiCorp Cloud Platform (HCP) Europe organization, you can manage user access and permissions through HCP \*\*groups\*\* and roles and then further refine those permissions with HCP Terraform roles. To learn more, refer to [HCP group roles and HCP Terraform permissions](#hcp-group-roles-and-hcp-terraform-permissions). ## Effective permissions You can set permissions at the following scopes: - [Organization permissions](/terraform/cloud-docs/users-teams-organizations/permissions/organization) - [Project permissions](/terraform/cloud-docs/users-teams-organizations/permissions/project) - [Workspace permissions](/terraform/cloud-docs/users-teams-organizations/permissions/workspace) Each permission is additive, granting a user the highest level of permissions possible, regardless of which scope set that permission. A team's \*\*effective permissions\*\* is the sum of the permissions that team has from every permission level. The scope that you grant a permission does not matter, the level of access that the permission grants determines what a user can do. For example, a team has [\*\*Manage all workspaces\*\*](/terraform/cloud-docs/users-teams-organizations/permissions/organization#manage-all-workspaces) permission for an organization, and the [\*\*Read\*\*](/terraform/cloud-docs/users-teams-organizations/permissions/workspace#read-role) role in a workspace, then the team has \*\*Manage all workspaces\*\* permissions for the workspace. HCP Terraform grants \*\*Manage all workspaces\*\* on that workspace because it is the most permissive level of access. Conversely, a team's organization permission does not override their workspace permission. For example, the [\*\*View all workspaces\*\*](/terraform/cloud-docs/users-teams-organizations/permissions/organization#view-all-workspaces) permission set for an organization does not override the [\*\*Write\*\*](/terraform/cloud-docs/users-teams-organizations/permissions/workspace#write-role) role set on a specific workspace. We recommend following the principle of least privilege when configuring permissions. Only grant users the permissions necessary to access the resources they need for their job function. ## Set permissions To learn how to set permissions for organizations, projects, and workspaces, refer to [Set permissions](/terraform/cloud-docs/users-teams-organizations/permissions/set-permissions). ## HCP group roles and HCP Terraform permissions In an HashiCorp Cloud Platform (HCP) Europe organization, you manage user access through groups. To learn more about HCP Europe, refer to [Use HCP Terraform in Europe](/terraform/cloud-docs/europe). To learn how to set up groups and assign users to them in HCP, refer to [Groups](/hcp/docs/hcp/iam/groups). You can assign permissions to groups in the following ways: - HCP roles: You can assign HCP roles to groups in HCP, and those roles automatically grant permissions in HCP Terraform. - HCP Terraform roles: Assign additional permissions at the organization, project, and workspace level to further refine group access in HCP Terraform. We recommend following the principle of least privilege when configuring roles. HCP roles grant permissions in HCP Terraform and other HCP services. If a group only needs to manage resources in HCP Terraform, assign roles in HCP Terraform and refrain from granting more permissive HCP roles. For example, to allow a user to view all workspaces in an organization in HCP Terraform, you could assign the \*\*View all workspaces\*\* permission in HCP Terraform at the organization-level, instead of the more permissive \*\*Viewer\*\* role in HCP. To learn how to set HCP Terraform roles for groups at the organization, project, and workspace level, refer to [Set permissions](/terraform/cloud-docs/users-teams-organizations/permissions/set-permissions). ## Permissions managed by external systems This documentation only refers to permissions that are managed by HCP Terraform and Terraform Enteprise. The permissions models of systems you integrate with can affect the overall security of your HCP Terraform or Terraform Enterprise organization. Consider the following examples: - When a workspace is connected to a VCS repository, anyone who can merge changes to that repository's main branch can indirectly queue plans in that workspace, regardless of whether they have explicit permission to queue plans or are even a member of your HCP Terraform organization. When auto-apply is enabled, merging changes indirectly start runs. - If you | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/permissions/index.mdx | main | terraform | [
-0.0018061234150081873,
0.020664606243371964,
-0.03277895599603653,
-0.02098512463271618,
-0.05760030448436737,
-0.029231518507003784,
-0.007975268177688122,
-0.05622563138604164,
0.005086319521069527,
0.07907333970069885,
-0.050330750644207,
-0.06708479672670364,
0.0154239721596241,
0.065... | 0.051201 |
repository, anyone who can merge changes to that repository's main branch can indirectly queue plans in that workspace, regardless of whether they have explicit permission to queue plans or are even a member of your HCP Terraform organization. When auto-apply is enabled, merging changes indirectly start runs. - If you use HCP Terraform's API to create a Slack bot for provisioning infrastructure, anyone who is able to issue commands to that Slack bot can implicitly act with that bot's permissions, regardless of their own membership and permissions in the HCP Terraform organization. - When a run task sends a request to an integrator, it provides an access token that provides access depending on the run task stage: - For post-plan, it provides access to the run plan JSON and the run task callback. - All access tokens created for run tasks have a lifetime of 10 minutes When integrating HCP Terraform with other systems, you are responsible for understanding the effects on your organization's security. An integrated system is able to delegate any level of access that it has been granted, so carefully consider the conditions and events that will cause it to delegate that access. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/permissions/index.mdx | main | terraform | [
-0.036285433918237686,
-0.009013650007545948,
0.02599833533167839,
-0.027987172827124596,
-0.02791847661137581,
-0.03671242296695709,
0.0167541466653347,
-0.03025195002555847,
0.006558247376233339,
0.06934677809476852,
-0.03252637758851051,
-0.02549975924193859,
0.02695414051413536,
-0.007... | 0.132378 |
# Organization permissions Organization-level permissions apply to all projects, Stacks, and workspaces within an organization. ## Background If you are in an HCP Terraform organization, you can manage user access and permissions through teams. Refer to the following topics for information about setting permissions in HCP Terraform: - [Set permissions](/terraform/cloud-docs/users-teams-organizations/permissions/set-permissions) - [Project permissions reference](/terraform/cloud-docs/users-teams-organizations/permissions/project) - [Workspace permissions reference](/terraform/cloud-docs/users-teams-organizations/permissions/workspace) - [Effective permissions](/terraform/cloud-docs/users-teams-organizations/permissions#effective-permissions) provides information about competing permissions. @include 'eu/permissions.mdx' ## All organization permissions The following table summarizes the available organization-level permission categories. Click on a specific permission to learn more about what that permission grants. | Permission category | Description | |---------------------|-------------| | [Project permissions](#project-permissions) | Control access to projects across the organization. | | [Workspace permissions](#workspace-permissions) | Control access to workspaces across the organization. | | [Team permissions](#team-permissions) | Control team management capabilities for the organization. If you are using an HCP Europe organization, refer to [Group permissions](#group-permissions) instead. | | [Settings permissions](#settings-permissions) | Control access to governance and infrastructure tools. | | [Private registry permissions](#private-registry-permissions) | Control access to the organization's private registry. | | [Public registry permissions](#public-registry-permissions) | Control access to the public registry. | ## Project permissions The following table summarizes the available organization-level permissions for projects. Click on a specific permission name to learn more about that permission level. | Permission name | Description | |---------------------|------------|-------------| | [None](#project-none) | No access to projects, and access must be granted individually. | | [View all projects](#view-all-projects) | Can view all project names in the organization. | | [Manage all projects](#manage-all-projects) | Can create, edit, and delete projects, and manage team access to all projects. | In HCP Europe organizations, you cannot assign \*\*Project permissions\*\* to a group in HCP Terraform. Instead, assign an HCP role that grants \*\*Project permissions\*\* to a group, then HCP Terraform automatically inherits those permissions. To learn more about which HCP roles grant which permissions, refer to [HCP group roles](#hcp-group-roles). ### None Members do not have access to projects or workspaces and Stacks. You can grant permissions to individual projects or workspaces and Stacks through [Project Permissions](/terraform/cloud-docs/users-teams-organizations/permissions/set-permissions#set-project-level-roles) or [Workspace Permissions](/terraform/cloud-docs/users-teams-organizations/permissions/set-permissions#set-workspace-level-roles). ### View all projects Members can view all projects within the organization. This lets users: - View project names in a given organization. ### Manage all projects Members can create and manage all projects and workspaces or Stacks within the organization. In addition to the permissions granted when enabling the [\*\*Manage all workspaces\*\*](#manage-all-workspaces) permission, this also lets users perform the following actions: - Manage other teams' access to all projects. - Create, edit, and delete projects that are otherwise only available to organization owners. - Create, read, update, and delete Stacks. - Initiate, cancel, or apply runs for Stacks. - Move workspaces and Stacks between projects. ## Workspace permissions The following table summarizes the available organization-level permissions for workspaces. Click on a specific permission name to learn more about that permission level. | Permission name | Description | |-----------------|-------------| | [None](#workspace-none) | No access to workspaces, and access must be granted individually. | | [View all workspaces](#view-all-workspaces) | Can view information about all workspaces. | | [Manage all workspaces](#manage-all-workspaces) | Admin permissions on all workspaces and can create workspaces. | ### None Members do not have access to projects or workspaces. You can grant permissions to individual projects or workspaces through [Project Permissions](/terraform/cloud-docs/users-teams-organizations/permissions/project) or [Workspace Permissions](/terraform/cloud-docs/users-teams-organizations/permissions/workspace). #### View all workspaces Members can view all workspaces within the organization. This lets users view information and features relevant to each workspaces, such as runs, state versions, variables. #### Manage all workspaces Members can create and manage all workspaces within the organization. This lets users perform the | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/permissions/organization.mdx | main | terraform | [
0.0087858522310853,
0.0010834441054612398,
-0.02476167306303978,
-0.03420340642333031,
-0.00759041728451848,
-0.020332708954811096,
-0.031770821660757065,
-0.09090519696474075,
-0.0051049175672233105,
0.037819456309080124,
-0.04835626110434532,
-0.05237188935279846,
0.0037438978906720877,
... | 0.048397 |
[Workspace Permissions](/terraform/cloud-docs/users-teams-organizations/permissions/workspace). #### View all workspaces Members can view all workspaces within the organization. This lets users view information and features relevant to each workspaces, such as runs, state versions, variables. #### Manage all workspaces Members can create and manage all workspaces within the organization. This lets users perform the following actions: - Any action that requires admin permissions in those workspaces. - Create new workspaces within the organization's \*\*Default Project\*\*, which is an action that is otherwise only available to organization owners. - Create, update, and delete [variable sets](/terraform/cloud-docs/workspaces/variables/managing-variables#variable-sets). ## Group Permissions In HashiCorp Cloud Platform (HCP) Europe organizations, you manage user access through HCP groups, and use group permissions instead of team permissions. To learn more, refer to [Use HCP Terraform in Europe](/terraform/cloud-docs/europe). You cannot manually assign \*\*Group permissions\*\* to a group in HCP Terraform. Instead, you must assign an HCP role to that group which grants \*\*Group permissions\*\*, then HCP Terraform automatically inherits those permissions. To learn more about which HCP roles grant group permissions, refer to [HCP group roles](#hcp-group-roles). ## Team permissions Team permissions are not available in HCP Europe organizations. To learn more, refer to [Group permissions](#group-permissions). Team permissions are available in standard HCP Terraform organizations. | Permission name | Description | |-----------------|-------------| | [Manage membership](#manage-membership) | Invite, remove, and add users to the team | | [Manage teams](#manage-teams) | Create, update, delete teams and [generate tokens](/terraform/cloud-docs/users-teams-organizations/api-tokens#team-api-tokens) | | [Manage organization access](#manage-organization-access) | Update team organization access settings | | [Include secret teams](#include-secret-teams) | Access and modify secret teams | | [Allow member token management](#allow-member-token-management) | Control team token management for team members | You can enable the following team management permissions in HCP Terraform: - \*\*Manage membership\*\* - \*\*Manage teams\*\* - \*\*Manage organization access\*\* Each permission level grants users the ability to perform specific actions and each progressively requires prerequisite permissions. For example, you must have the \*\*Manage teams\*\* permission to grant another user the \*\*Manage teams\*\* permission, and that user must already have \*\*Manage membership\*\* permissions. To grant a user \*\*Manage organization access\*\*, a user must already have \*\*Manage membership\*\* and \*\*Manage teams\*\* permissions. ### Manage membership Allows members to invite users to the organization, remove users from the organization, and add or remove users from teams within the organization. This permission grants the ability to view the list of users within the organization, and to view the organization access of other visible teams. It does not permit the creation of teams, the ability to modify the settings of existing teams, or the ability to view secret teams. In order to modify the membership of a team, the user must be a member of a team with the \*\*Manage membership\*\* permissions enabled and the [\*\*Visible\*\*](/terraform/cloud-docs/users-teams-organizations/teams/manage#team-visibility) setting must be enabled for the team. The user can also be a member of the team if the \*\*Visible\*\* setting is disabled. In order to remove a user from the organization, the holder of this permission must have visibility into all of the teams which the user is a member of. Owners of large organizations can use this permission to delegate membership management to another trusted team and should only grant this permission to teams of trusted users. Users with this permission are able to add themselves to any visible team and inherit the permissions of any visible team. ### Manage teams Allows members to create, update, and delete teams. It also lets members generate and revoke tokens. This permission grants the ability to update a team's names, SSO IDs, and token management permissions, but does not allow access to organization settings. On its own, this permission | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/permissions/organization.mdx | main | terraform | [
0.02480076625943184,
0.004465512931346893,
-0.04135824367403984,
-0.018110085278749466,
-0.020206322893500328,
-0.03516865894198418,
-0.005918250419199467,
-0.09193680435419083,
-0.005059193354099989,
0.06642001122236252,
-0.007223811000585556,
-0.05481252074241638,
0.01344834454357624,
0.... | 0.058655 |
visible team. ### Manage teams Allows members to create, update, and delete teams. It also lets members generate and revoke tokens. This permission grants the ability to update a team's names, SSO IDs, and token management permissions, but does not allow access to organization settings. On its own, this permission does not allow users to create, update, delete, or otherwise access secret teams. The manage teams permission confers all permissions granted by the manage membership permission. This permission allows owners of large organizations to delegate team management to another trusted team. You should only grant it to teams of trusted users. Users with this permission can update or delete any visible team. Because this permission also confers the manage membership permission, a user with the manage teams permission can add themselves to any visible team. ### Manage organization access Allows members to update a team's organization access settings. On its own, this permission does not allow users to create, update, delete, or otherwise access secret teams. This permission confers all of the permissions granted by the manage teams and manage membership permissions. This permission allows owners of large organizations to delegate team management to another trusted team. You should only grant it to teams of trusted users. Members with this permission can update all organization access settings for any team visible to them. ### Include secret teams Allows members access to secret teams at the level permitted by that user's team permissions setting. This permission modifies existing team management permissions. Members with this permission can access secret teams up to the level permitted by other team management permissions. For example, if a user has permission to include secret teams and [manage teams](#manage-teams), that user can create secret teams. ### Allow member token management Allows owners and members with [manage teams](#manage-teams) permissions to enable and disable team token management for team members. This permission defaults to `true`. When member token management is enabled, members will be able to perform actions on team tokens, including generating and revoking a team token. When member token management is disabled, members will be unable to perform actions on team tokens, including generating and revoking a team token. ## Settings permissions The following permissions control access to governance and infrastructure tools. | Permission name | Description | |-----------------|-------------| | [Manage policies](#manage-policies) | Create, edit, read, list and delete Sentinel policies | | [Manage policy overrides](#manage-policy-overrides) | Override soft-mandatory policy checks | | [Manage run tasks](#manage-run-tasks) | Create, edit, and delete run tasks | | [Manage version control settings](#manage-version-control-settings) | Manage VCS providers and SSH keys | | [Manage agent pools](#manage-agent-pools) | Create, edit, and delete agent pools | ### Manage policies Allows members to create, edit, read, list and delete the organization's Sentinel policies. This permission implicitly gives permission to read runs on all workspaces, which is necessary to set enforcement of [policy sets](/terraform/cloud-docs/policy-enforcement/manage-policy-sets). ### Manage run tasks Allows members to create, edit, and delete run tasks on the organization. ### Manage policy overrides Allows members to override soft-mandatory policy checks. This permission implicitly gives permission to read runs on all workspaces, which is necessary to override policy checks. ### Manage VCS settings Allows members to manage the set of [VCS providers](/terraform/cloud-docs/vcs) and [SSH keys](/terraform/cloud-docs/vcs#ssh-keys) available within the organization. ### Manage agent pools Allows members to create, edit, and delete agent pools within their organization. This permission implicitly grants access to read all workspaces and projects, which is necessary for agent pool management. ## Private registry permissions The following permissions control access to the organization's [private registry](/terraform/cloud-docs/registry). | Permission name | Description | |-----------------|-------------| | [Manage | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/permissions/organization.mdx | main | terraform | [
-0.04018210992217064,
-0.02565048448741436,
-0.06384637206792831,
0.055406082421541214,
0.035194460302591324,
0.010552257299423218,
0.019924987107515335,
-0.05604296922683716,
0.051365192979574203,
0.010402917861938477,
0.005095039028674364,
0.027034036815166473,
0.08235741406679153,
0.058... | 0.123804 |
create, edit, and delete agent pools within their organization. This permission implicitly grants access to read all workspaces and projects, which is necessary for agent pool management. ## Private registry permissions The following permissions control access to the organization's [private registry](/terraform/cloud-docs/registry). | Permission name | Description | |-----------------|-------------| | [Manage modules](#manage-private-modules) | Publish and delete modules in the private registry | | [Manage providers](#manage-private-providers) | Publish and delete providers in the private registry | | [Manage Stack component configurations](#manage-stack-component-configurations) | Publish and delete Stack component configurations in the private registry | ### Manage private modules Allow members to publish and delete modules in the organization's private registry. ### Manage private providers Allow members to publish and delete providers in the organization's private registry. ### Manage Stack component configurations Allow members to [publish and delete Stack component configurations](/terraform/cloud-docs/registry/publish-stack-configuration) in the organization's private registry. ## Public registry permissions The following permissions control access to providers and modules using an organization's [claimed namespaces](/terraform/cloud-docs/registry/public-namespace) in the [public registry](https://registry.terraform.io/). | Permission name | Description | |-----------------|-------------| | [Manage public modules](#manage-public-modules) | Publish and delete modules for the organization in the public registry | | [Manage public providers](#manage-public-providers) | Publish and delete providers for the organization in the public registry | ### Manage public modules Allow members to publish and delete modules for the organization in the public registry. ### Manage public providers Allow members to publish and delete providers for the organization in the public registry. ## Organization owners If you are using an HCP Europe organization, there is no organization owners team because you manage users with HCP groups. To learn more, refer to [HCP group roles](#hcp-group-roles). Every organization has an \*\*Owners\*\* team whose members have the maximum available permissions within the organization. This includes all organization-level permissions and the highest level of permissions on every workspace and Stack. There are also some actions within an organization that are only available to owners. These are generally actions that affect the permissions and membership of other teams, or are otherwise fundamental to the organization's security and integrity. The organization owners team has the following permissions: | Permission | Description | |------------|-------------| | [Manage all projects](#project-permissions) | Admin permissions on every project. | | [Manage all workspaces](#workspace-permissions) | Admin permissions on every workspace. | | [Manage membership](#team-permissions) | Invite/remove users and manage team membership. | | [Manage teams](#team-permissions) | Create, update, delete teams and generate tokens. | | [Manage organization access](#team-permissions) | Update team organization access settings. | | [Include secret teams](#team-permissions) | View and manage all secret teams. | | [Allow member token management](#team-permissions) | Control team token management for members. | | [Manage policies](#settings-permissions) | Create, edit, delete Sentinel policies. | | [Manage policy overrides](#settings-permissions) | Override soft-mandatory policy checks. | | [Manage run tasks](#settings-permissions) | Create, edit, delete run tasks. | | [Manage version control settings](#settings-permissions) | Manage VCS providers and SSH keys. | | [Manage agent pools](#settings-permissions) | Create, edit, delete agent pools. | | [Manage modules](#private-registry-permissions) | Publish and delete modules in private registry. | | [Manage providers](#private-registry-permissions) | Publish and delete providers in private registry. | | [Manage public modules](#public-registry-permissions) | Publish and delete modules in public registry. Only available in HCP Terraform. | | [Manage public providers](#public-registry-permissions) | Publish and delete providers in public registry. Only available in HCP Terraform. | | Manage all organization settings | Control organization-wide settings. Only available for the owners team. | | Manage organization billing | Control billing and subscriptions. Only available for the owners team, and only available in HCP Terraform. | | Delete organization | Permanently delete the organization. Only available | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/permissions/organization.mdx | main | terraform | [
-0.013833141885697842,
-0.04041657596826553,
-0.04586763679981232,
0.020073624327778816,
0.005836915224790573,
-0.01918831840157509,
-0.006902376655489206,
-0.12277255952358246,
0.02729380875825882,
0.09834236651659012,
0.004999266471713781,
-0.04625174403190613,
0.04136919975280762,
0.054... | 0.046321 |
Terraform. | | Manage all organization settings | Control organization-wide settings. Only available for the owners team. | | Manage organization billing | Control billing and subscriptions. Only available for the owners team, and only available in HCP Terraform. | | Delete organization | Permanently delete the organization. Only available for the owners team. | ## HCP group roles In an HCP Europe organization, you manage user access through groups. To learn how to set up groups and assign users to them in HCP, refer to [Groups](/hcp/docs/hcp/iam/groups). To learn more about HCP Terraform in Europe, refer to [Use HCP Terraform in Europe](/terraform/cloud-docs/europe). You can assign permissions to HCP groups in two ways: - [HCP roles](/terraform/cloud-docs/users-teams-organizations/permissions/set-permissions#set-organization-level-roles-for-hcp-europe-organizations) - You can assign HCP roles to groups in the HashiCorp Cloud Platform (HCP), and these roles automatically grant permissions in HCP Terraform. - [HCP Terraform roles](/terraform/cloud-docs/users-teams-organizations/permissions/set-permissions#set-organization-level-permissions - Assign additional permissions at the organization, project, and workspace level to further refine group access in HCP Terraform. Each permission a user is granted is additive. HCP Terraform grants a user the highest permissions possible, regardless of whether that permission was set by an HCP or HCP Terraform role. The following table lists which organization-level permissions each HCP role automatically grants in HCP Terraform: | HCP Terraform organization permission | Admin | Contributor | Viewer | |---------------------------------------|-------|-------------|---------| | [Owner-level permissions](#organization-owners) | β
| β | β | | [View all projects](#view-all-projects) | β
| β
| β
| | [Manage all projects](#manage-all-projects) | β
| β
| β | | [View all workspaces](#view-all-workspaces) | β
| β
| β
| | [Manage all workspaces](#manage-all-workspaces) | β
| β
| β | | [Manage organization access](#manage-organization-access) | β
| β | β | | [Include secret groups](#include-secret-groups) | β
| β | β | | [Manage policies](#manage-policies) | β
| β | β | | [Manage policy overrides](#manage-policy-overrides) | β
| β | β | | [Manage run tasks](#manage-run-tasks) | β
| β | β | | [Manage version control settings](#manage-version-control-settings) | β
| β | β | | [Manage agent pools](#manage-agent-pools) | β
| β | β | | [Manage private registry modules](#manage-private-modules) | β
| β | β | | [Manage private registry providers](#manage-private-providers) | β
| β | β | | [Manage public registry modules](#manage-public-modules) | β
| β | β | | [Manage public registry providers](#manage-public-providers) | β
| β | β | | Members can manage API tokens | β
| β
| β | | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/permissions/organization.mdx | main | terraform | [
0.0364578552544117,
0.016487685963511467,
-0.049437541514635086,
-0.04645221307873726,
-0.036711301654577255,
-0.015691105276346207,
-0.024667847901582718,
-0.07022854685783386,
-0.0032604828011244535,
0.026031944900751114,
-0.014636868610978127,
-0.08027713745832443,
0.027771512046456337,
... | 0.056483 |
# Set permissions In HCP Terraform you can set individual permissions and sets of permissions to control what your users can do. You can assign permissions at the organization, project, and workspace levels to control user access and the actions they can take. > \*\*Hands-on:\*\* Try the [Manage Permissions in HCP Terraform](/terraform/tutorials/cloud/cloud-permissions?utm\_source=WEBSITE&utm\_medium=WEB\_IO&utm\_offer=ARTICLE\_PAGE&utm\_content=DOCS) tutorial. ## Background @include 'tfc-package-callouts/team-management.mdx' If you are in an HCP Terraform organization, you can manage user access and permissions through \*\*teams\*\*. Each permission a user is granted is additive. HCP Terraform grants a user the highest permissions possible, regardless of whether that permission was set by an organization, project, or workspace. To learn more, refer to [Effective permissions](/terraform/cloud-docs/users-teams-organizations/permissions#effective-permissions). The following sections explain how to set permissions in HCP Terraform: - [Set organization-level permissions](#set-organization-level-permissions) - [Set project-level permissions](#set-project-level-permissions) - [Set workspace-level permissions](#set-workspace-level-permissions) ### HCP Europe organizations In an HashiCorp Cloud Platform (HCP) Europe organization, you manage user access through \*\*groups\*\*. To learn how to set up groups and assign users to them in HCP, refer to [Groups](/hcp/docs/hcp/iam/groups). To learn more about HCP Europe, refer to [Use HCP Terraform in Europe](/terraform/cloud-docs/europe). You can assign permissions to groups in the following ways: - HCP roles: You can assign HCP roles to groups in HCP, and those roles automatically grant permissions in HCP Terraform. - HCP Terraform roles: Assign additional permissions at the organization, project, and workspace level to further refine group access in HCP Terraform. Each permission a user is granted is additive. HCP Terraform grants a user the highest permissions possible, regardless of whether that permission was set by an HCP or HCP Terraform role, or whether the role was set by an organization, project, or workspace. To learn more, refer to [Effective permissions](/terraform/cloud-docs/users-teams-organizations/permissions#effective-permissions). The following sections explain how to set permissions in HCP Terraform: - [Set organization-level roles for HCP Europe organizations](#set-organization-level-roles-for-hcp-europe-organizations) - [Set project-level roles for HCP Europe organizations](#set-project-level-roles-for-hcp-europe-organizations) - [Set workspace-level roles for HCP Europe organizations](#set-workspace-level-roles-for-hcp-europe-organizations) ## Set organization-level permissions To learn how set roles in HCP Europe organizations, refer to [Set organization-level roles for HCP Europe organizations](#set-organization-level-roles-for-hcp-europe-organizations). To set organization-level permissions for a team, perform the following steps: 1. Navigate to your organization's \*\*Settings\*\* page. 1. Click \*\*Teams\*\*, then select the team name from the list. 1. Assign the permissions you want to grant team members across your organization. 1. Click \*\*Update team organization access\*\* to save the permissions. For more information about what each permission grants, refer to [Organization permissions](/terraform/cloud-docs/users-teams-organizations/permissions/organization). ## Set organization-level roles for HCP Europe organizations If your URL includes `portal.cloud.eu.hashicorp` or `app.eu.terraform.io`, then you are in an HashiCorp Cloud Platform (HCP) Europe organization. If you are not in an HCP Europe organization, refer to [Set organization-level permissions](#set-organization-level-permissions. If you are in an HCP Europe organization, HCP Terraform inherits the groups and roles you define in HCP. To learn about creating groups and managing users, refer to [HCP Groups](/hcp/docs/hcp/iam/groups). You can assign organization-level permissions to groups in the following ways: - HCP roles: Assign HCP roles to groups in HCP, and those roles automatically grant permissions in HCP Terraform. - HCP Terraform roles: Assign additional permissions to refine access to the organization in HCP Terraform. To add a new organization-level role for your group in HCP Terraform, perform the following steps: 1. Navigate to your organization in HCP Terraform EU. Your URL must include `app.eu.terraform.io`. 1. Select \*\*Settings\*\*, then \*\*Role assignments\*\* in the side navigation. 1. Click \*\*+ Add new assignment\*\*. 1. Select a group to assign a Terraform role to, then click \*\*Select group\*\*. 1. Alternatively, open the ellipses menu for a group and complete the following steps: 1. Select \*\*View | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/permissions/set-permissions.mdx | main | terraform | [
0.0012724546249955893,
0.03682946786284447,
-0.032742105424404144,
-0.04668402671813965,
-0.04800199717283249,
-0.030142420902848244,
0.015371207147836685,
-0.04768606275320053,
0.018159594386816025,
0.07154203206300735,
-0.02750529535114765,
-0.07010607421398163,
0.019691718742251396,
0.0... | 0.041251 |
must include `app.eu.terraform.io`. 1. Select \*\*Settings\*\*, then \*\*Role assignments\*\* in the side navigation. 1. Click \*\*+ Add new assignment\*\*. 1. Select a group to assign a Terraform role to, then click \*\*Select group\*\*. 1. Alternatively, open the ellipses menu for a group and complete the following steps: 1. Select \*\*View organization-level permissions\*\*. 1. Select \*\*Manage roles\*\*. 1. Click \*\*Edit Terraform Roles\*\*. To manage your HCP organization role, you can alternatively select \*\*Manage roles on HCP\*\* to navigate to HCP. To learn more about using roles and HCP groups, refer to [HCP group roles and HCP Terraform permissions](/terraform/cloud-docs/users-teams-organizations/permissions#hcp-group-roles-and-hcp-terraform-permissions). To learn about the specific permissions you can assign to organizations in HCP Terraform, refer to [Organization permissions](/terraform/cloud-docs/users-teams-organizations/permissions/organization). ## Set project-level permissions To learn how set roles in HCP Europe organizations, refer to [Set project-level roles for HCP Europe organizations](#set-project-level-roles-for-hcp-europe-organizations). To set project-level permissions for a team, perform the following steps: 1. Navigate to your organization's \*\*Projects\*\* page. 1. Select a project from the list, then select \*\*Settings\*\* in the side navigation. 1. Click \*\*Team access\*\*, and select the team name from the list or click \*\*+ Add team\*\* to add a new team assignment. 1. Choose one of the preset permission set roles, or set individual permissions to create a custom role. 1. Click \*\*Assign permissions\*\* to save the settings. For more information about each permission, refer to [Project permissions](/terraform/cloud-docs/users-teams-organizations/permissions/project). ## Set project-level roles for HCP Europe organizations If your URL includes `portal.cloud.eu.hashicorp` or `app.eu.terraform.io`, then you are in an HashiCorp Cloud Platform (HCP) Europe organization. If you are not in an HCP Europe organization, refer to [Set project-level permissions](#set-project-level-permissions). If you are in an HCP Europe organization, HCP Terraform inherits the groups and roles you define in HCP. To learn about creating groups and managing users, refer to [HCP Groups](/hcp/docs/hcp/iam/groups). You can assign project-level roles to groups in the following ways: - HCP roles: Assign HCP roles to groups in HCP, and those roles automatically grant permissions in HCP Terraform. - HCP Terraform roles: Assign additional permissions to refine access to the project in HCP Terraform. To add a new project-level role for your group in HCP Terraform, perform the following steps: 1. Navigate to your organization in HCP Terraform EU. Your URL must include `app.eu.terraform.io`. 1. Select a project from the list. 1. Select \*\*Settings\*\*, then \*\*Role assignments\*\* from the side navigation. 1. Click \*\*+ Add new assignment\*\*. 1. Select a role and a group, then click \*\*Assign role\*\*. 1. Alternatively, open the ellipses menu for a group and complete the following steps: 1. Select \*\*View project-level permissions\*\*. 1. Select \*\*Manage roles\*\*. 1. Click \*\*Edit Terraform Roles\*\*. To manage your HCP project role, you can alternatively select \*\*Manage roles on HCP\*\* to navigate to HCP. To learn more about using roles and HCP groups, refer to [HCP group roles and HCP Terraform permissions](/terraform/cloud-docs/users-teams-organizations/permissions#hcp-group-roles-and-hcp-terraform-permissions). To learn about the specific permissions you can assign to projects in HCP Terraform, refer to [Project permissions](/terraform/cloud-docs/users-teams-organizations/permissions/project). ## Set workspace-level permissions To learn how set roles in HCP Europe organizations, refer to [Set workspace-level roles for HCP Europe organizations](#set-workspace-level-roles-for-hcp-europe-organizations). To set workspace-level permissions for a team, perform the following steps: 1. Navigate to your organization's \*\*Workspaces\*\* page. 1. Select a workspace from the list, then select \*\*Settings\*\* in the side navigation. 1. Click \*\*Team access\*\*, and select the team name from the list or click \*\*+ Add team and permissions\*\* to add a new team assignment. 1. Choose one of the preset permission set roles, or set individual permissions to create a custom role. 1. Click \*\*Assign permissions\*\* to save the settings. For more information about | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/permissions/set-permissions.mdx | main | terraform | [
0.018845371901988983,
0.004367074463516474,
-0.0037320274859666824,
-0.025758318603038788,
-0.025865187868475914,
-0.010590464808046818,
-0.02084590680897236,
-0.05654674395918846,
-0.02230982668697834,
0.08111800998449326,
-0.03804738447070122,
-0.10167022049427032,
0.03418263792991638,
0... | 0.032186 |
select the team name from the list or click \*\*+ Add team and permissions\*\* to add a new team assignment. 1. Choose one of the preset permission set roles, or set individual permissions to create a custom role. 1. Click \*\*Assign permissions\*\* to save the settings. For more information about each permission, refer to [Workspaces permissions](/terraform/cloud-docs/users-teams-organizations/permissions/workspace). ## Set workspace-level roles for HCP Europe organizations If your URL includes `portal.cloud.eu.hashicorp` or `app.eu.terraform.io`, then you are in an HashiCorp Cloud Platform (HCP) Europe organization. If you are not in an HCP Europe organization, refer to [Set workspace-level permissions](#set-project-level-permissions). If you are in an HCP Europe organization, HCP Terraform inherits the groups and roles you define in HCP. To learn about creating groups and managing users, refer to [HCP Groups](/hcp/docs/hcp/iam/groups). You can assign roles to groups in two ways: - HCP roles - You can assign HCP roles to groups in HCP, and those roles automatically grant permissions in HCP Terraform. - HCP Terraform roles - Assign additional permissions to refine access to the project in HCP Terraform. To add a new workspace-level role for your group in HCP Terraform, perform the following steps: 1. Navigate to your organization in HCP Terraform EU, your URL must include `app.eu.terraform.io`. 1. Navigate to your organization's \*\*Workspaces\*\* page. 1. Select a workspace from the list. 1. Select \*\*Settings\*\*, then \*\*Role assignments\*\* from the side navigation. 1. Click \*\*+ Add new assignment\*\*. 1. Select a role and a group to assign, then click \*\*Assign role\*\*. 1. Alternatively, open the ellipses menu for a group and complete the following steps: 1. Select \*\*View workspace-level permissions\*\*. 1. Select \*\*Manage roles\*\*. 1. Click \*\*Edit Terraform Roles\*\*. To learn more about using roles and HCP groups, refer to [HCP group roles and HCP Terraform permissions](/terraform/cloud-docs/users-teams-organizations/permissions#hcp-group-roles-and-hcp-terraform-permissions). To learn about the specific permissions you can assign to workspaces in HCP Terraform, refer to [Workspace permissions](/terraform/cloud-docs/users-teams-organizations/permissions/workspace). | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/permissions/set-permissions.mdx | main | terraform | [
0.027763599529862404,
0.003306084545329213,
-0.05180668830871582,
-0.031954098492860794,
-0.035751599818468094,
-0.010598747059702873,
-0.018085580319166183,
-0.059046823531389236,
0.00388059439137578,
0.0568106435239315,
-0.036032259464263916,
-0.08432992547750473,
0.02434198372066021,
0.... | 0.045651 |
# Workspace permissions Workspace-level permissions apply to a specific workspace and control what users can do within that workspace. ## Background If you are in an HCP Terraform organization, you can manage user access and permissions through teams. Refer to the following topics for information about setting permissions in HCP Terraform: - [Set permissions](/terraform/cloud-docs/users-teams-organizations/permissions/set-permissions) - [Organization permissions reference](/terraform/cloud-docs/users-teams-organizations/permissions/organization) - [Project permissions reference](/terraform/cloud-docs/users-teams-organizations/permissions/project) - [Effective permissions](/terraform/cloud-docs/users-teams-organizations/permissions#effective-permissions) provides information about competing permissions. @include 'eu/permissions.mdx' ## Workspace roles and permissions A role is a preselected set of permissions that you can assign to a team or group. The following table shows the permissions granted by each workspace role. Each role builds upon the previous level, with \*\*Admin\*\* granting the most comprehensive access. | Permission category | Permission name | [Admin](#workspace-admin) | [Write](#workspace-write) | [Plan](#workspace-plan) | [Read](#workspace-read) | |---------------------|------------|:-----:|:-----:|:----:|:----:| | [Run access](#run-access) | [Read runs](#run-read) | β
| β
| β
| β
| | | [Plan runs](#run-plan) | β
| β
| β
| β | | | [Apply runs](#run-apply) | β
| β
| β | β | | [Variable access](#variable-access) | [Read variables](#variable-read) | β
| β
| β
| β
| | | [Read and write variables](#variable-read-write) | β
| β
| β | β | | [State access](#state-access) | [Read outputs only](#state-read-outputs) | β
| β
| β
| β
| | | [Read state](#state-read) | β
| β
| β
| β
| | | [Read and write state](#state-read-write) | β
| β
| β | β | | [Other controls](#other-controls) | [Download Sentinel mocks](#download-sentinel-mocks) | β
| β
| β | β | | | [Lock/unlock workspace](#lock-unlock-workspace) | β
| β
| β | β | | | [Manage workspace Run Tasks](#manage-workspace-run-tasks) | β
| β | β | β | | [Admin-only permissions](#workspace-admin) | Read and write workspace settings | β
| β | β | β | | | Set workspace permissions for visible teams | β
| β | β | β | | | Delete workspace | β
| β | β | β | ### Workspace admin Much like the owners team has full control over an organization, each workspace has a special \*\*Admin\*\* permissions set that grants full control over the workspace. Members of a team with admin permissions on a workspace are sometimes called "workspace admins" for that workspace. Admin permissions include the highest level of general permissions for the workspace. There are also some permissions that are only available to workspace admins, which generally involve changing the workspace's settings or setting access levels for other teams. Workspace admins have all other [workspace permissions](#workspace-roles-and-permissions), as well as the ability to do the following: - Read and write workspace settings, such as general settings, notification configurations, and run triggers. - Set or remove workspace permissions for visible teams. Workspace admins cannot view or manage teams with the [\*\*Secret\*\*](/terraform/cloud-docs/users-teams-organizations/teams/manage#team-visibility) visibility option enabled unless they are also organization owners. - Delete the workspace - Depending on the [organization's settings](/terraform/cloud-docs/users-teams-organizations/organizations#general), workspace admins may only be able to delete the workspace if it is not actively managing infrastructure. Refer to [Deleting a Workspace With Resources Under Management](/terraform/cloud-docs/workspaces/settings#deleting-a-workspace-with-resources-under-management) for details. ### Workspace write The \*\*Write\*\* permission set is for people who do most of the day-to-day work of provisioning and modifying managed infrastructure. Write access grants the following workspace permissions: - Plan and apply workspace runs. - Read and write the workspace has access to. - Read and write to the state of a workspace. - Lock and unlock the workspace. - Download Sentinel mocks. Refer to [Workspace roles and permissions](#workspace-roles-and-permissions) for details about specific permissions. | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/permissions/workspace.mdx | main | terraform | [
-0.00788637064397335,
0.005422177258878946,
-0.004446906037628651,
-0.011326385661959648,
0.005618353374302387,
-0.02161487005650997,
0.009517987258732319,
-0.09527748078107834,
0.00903384480625391,
0.04481390118598938,
-0.04180365800857544,
-0.05591211095452309,
0.015553619712591171,
0.06... | 0.049974 |
the following workspace permissions: - Plan and apply workspace runs. - Read and write the workspace has access to. - Read and write to the state of a workspace. - Lock and unlock the workspace. - Download Sentinel mocks. Refer to [Workspace roles and permissions](#workspace-roles-and-permissions) for details about specific permissions. ### Workspace plan The \*\*Plan\*\* permission set is for people who might propose changes to managed infrastructure, but whose proposed changes should be approved before they are applied. Plan access grants the following workspace permissions: - Plan workspace runs. - Read variables the workspace has access to. - Read the state of a workspace. Refer to [Workspace roles and permissions](#workspace-roles-and-permissions) for details about specific permissions. ### Workspace read The \*\*Read\*\* permission set is for people who need to view information about the status and configuration of managed infrastructure in order to do their jobs, but aren't responsible for maintaining that infrastructure. Read access grants the following workspace permissions: - Read workspace runs. - Read variables the workspace has access to. - Read the state of a workspace. Refer to [Workspace roles and permissions](#workspace-roles-and-permissions) for details about specific permissions. ### Workspace custom role Custom permission sets let you assign a custom role with fine-grained permissions. Creating a custom role lets you create a task-focused permission set with a tighter control of sensitive information. You can use custom permissions to assign any of the permissions listed under [workspace roles and permissions](#workspace-roles-and-permissions), except admin-only permissions. ## Run access The following table summarizes the available run access permissions for the workspace. | Permission name | Description | |-----------------|-------------| | [Read](#run-read) | View information about workspace runs. | | [Plan](#run-plan) | Queue Terraform plans in the workspace. | | [Apply](#run-apply) | Approve and apply Terraform plans in the workspace. | ### Read Allows users to view information about remote Terraform runs. Users can view run history, the status of runs, configuration versions associated with a run, and the log output of each stage of a run. Refer to [Run states and stages](/terraform/cloud-docs/workspaces/run/states) for more information. ### Plan Allows users to read, queue, and comment on Terraform plans in a workspace. Regular plans require approval from a user with permission to apply runs. ### Apply Allows users to read, plan, approve, and apply Terraform plans. Granting this permission allows team members to change real infrastructure. ## Variable access The following table summarizes the available permissions for accessing workspace variables. | Permission name | Description | |-----------------|-------------| | [No access](#variable-no-access) | No access to workspace variables. | | [Read](#variable-read) | View workspace variables and environment variables. | | [Read and write](#variable-read-write) | Edit workspace variables and environment variables. | ### No access No access is granted to the values of Terraform variables and environment variables for the workspace. ### Read Allows users to view the values of Terraform variables and environment variables for the workspace. Note that variables marked as sensitive are write-only and can't be viewed by any user. ### Read and write Allows users to read and edit the values of variables in the workspace. ## State access The following table summarizes the available state access permissions for the workspace. | Permission name | Description | |-----------------|-------------| | [No access](#state-no-access) | No access to workspace state. | | [Read outputs only](#state-read-outputs) | Access public outputs from workspace state. | | [Read](#state-read) | Read complete state files from the workspace. | | [Read and write](#state-read-write) | Create new state versions in the workspace. | ### No access No access is granted to the state file from the workspace. ### Read outputs only Allows users to access | https://github.com/hashicorp/web-unified-docs/blob/main//content/terraform-docs-common/docs/cloud-docs/users-teams-organizations/permissions/workspace.mdx | main | terraform | [
-0.019417310133576393,
-0.015913045033812523,
-0.04084604233503342,
0.058255136013031006,
0.044978272169828415,
-0.05099703371524811,
0.04875997081398964,
-0.04930415004491806,
-0.06933247298002243,
0.0680025964975357,
-0.010021698661148548,
0.028437843546271324,
-0.030144929885864258,
0.0... | 0.11615 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.