You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/terraform/v1.13.x/docs/language/block/stack/component_configuration/index.mdx
-6Lines changed: 0 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,15 +20,9 @@ Each Stack requires at least one `component` block, and you must add a `componen
20
20
You can define the following blocks in component configuration files:
21
21
22
22
- The [`component`](/terraform/language/block/stack/configuration/component) block sources individual modules that make up your Stack. Each component receives input variables and accepts providers that you declare at the Stack level.
23
-
24
23
- The [`required_providers`](/terraform/language/block/stack/configuration/required_providers) block declares which providers your component configuration requires so that Terraform can install and use them.
25
-
26
24
- The [`provider`](/terraform/language/block/stack/configuration/provider) block configures providers and passes that configuration to components.
27
-
28
25
- The [`removed`](/terraform/language/block/stack/configuration/removed) block defines components you want to remove from your Stack while ensuring proper cleanup of resources.
29
-
30
26
- The [`variable`](/terraform/language/block/stack/configuration/variable) block defines input variables that your deployments can set with different values.
31
-
32
27
- The [`output`](/terraform/language/block/stack/configuration/output) block defines values to expose in the HCP Terraform UI and to make available to deployments.
33
-
34
28
- The [`locals`](/terraform/language/block/locals) block defines local values that you can reference within your component configuration.
Copy file name to clipboardExpand all lines: content/terraform/v1.13.x/docs/language/block/stack/deploy/deployment.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -120,7 +120,7 @@ deployment "<LABEL>" {
120
120
}
121
121
```
122
122
123
-
You can use deployment groups to enable orchestration rules which can manage your deployment's lifecycle. For more details on deployment groups, refer to the [Set conditions for deployment plans](/terraform/language/stacks/deploy/conditions).
123
+
You can use deployment groups to enable orchestration rules which can manage your deployment's lifecycle. For more details on deployment groups, refer to the [Set conditions for deployment runs](/terraform/language/stacks/deploy/conditions).
124
124
125
125
If a deployment does not specify a deployment group, Terraform automatically generates an independent deployment group for it named `<DEPLOYMENT_NAME>_default`.
126
126
@@ -215,7 +215,7 @@ deployment "web" {
215
215
}
216
216
```
217
217
218
-
You can use deployment groups to enable orchestration rules which can manage your deployment's lifecycle. For more details on deployment groups, refer to the [Set conditions for deployment plans](/terraform/language/stacks/deploy/conditions).
218
+
You can use deployment groups to enable orchestration rules which can manage your deployment's lifecycle. For more details on deployment groups, refer to the [Set conditions for deployment runs](/terraform/language/stacks/deploy/conditions).
Copy file name to clipboardExpand all lines: content/terraform/v1.13.x/docs/language/block/stack/deploy/deployment_group.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Deployment groups only support one deployment per group at this time.
17
17
18
18
The `deployment_group` block defines a new group that you can assign individual deployments to join. You can assign a deployment to a group [using the `deployment_group` argument in a `deployment` block](/terraform/language/block/stack/deploy/deployment#deployment_group). If you don't assign a deployment to a group, Terraform automatically creates a default deployment group for that deployment.
19
19
20
-
Deployment groups let you enforce orchestration rules on the deployments within the group. To learn more, refer to [Set conditions for deployment plans](/terraform/language/stacks/deploy/conditions).
20
+
Deployment groups let you enforce orchestration rules on the deployments within the group. To learn more, refer to [Set conditions for deployment runs](/terraform/language/stacks/deploy/conditions).
Copy file name to clipboardExpand all lines: content/terraform/v1.13.x/docs/language/block/stack/deploy/index.mdx
-7Lines changed: 0 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,17 +20,10 @@ To learn more, refer to [Define deployment configuration](/terraform/language/st
20
20
You can define the following blocks in deployment configuration files:
21
21
22
22
- The [`deployment`](/terraform/language/block/stack/deployment/deployment) block defines how many times you want to deploy your Stack's infrastructure and with what input values.
23
-
24
23
- The [`deployment_group`](/terraform/language/block/stack/deployment/deployment_group) block groups deployments together to configure shared settings and auto-approval rules.
25
-
26
24
- The [`deployment_auto_approve`](/terraform/language/block/stack/deployment/deployment_auto_approve) block defines rules that automatically approve deployment plans based on specific conditions.
27
-
28
25
- The [`identity_token`](/terraform/language/block/stack/deployment/identity_token) block defines JSON Web Tokens (JWT) that Terraform generates for OIDC authentication with cloud providers.
29
-
30
26
- The [`store`](/terraform/language/block/stack/deployment/store) block provides access to external secret stores and variable sets from your deployment configuration.
31
-
32
27
- The [`publish_output`](/terraform/language/block/stack/deployment/publish_output) block exports values from your Stack that other Stacks in the same project can consume.
33
-
34
28
- The [`upstream_input`](/terraform/language/block/stack/deployment/upstream_input) block consumes outputs from another Stack in the same project and uses them as inputs in your current Stack.
35
-
36
29
- The [`locals`](/terraform/language/block/locals) block defines local values that you can reference within your deployment configuration.
page_title: Stack configuration files for Terraform
3
+
description: |-
4
+
Learn about the two types of configuration files that make up a Stack. The component configuration file defines the pieces that make up a Stack, and deployment configuration files defines how to deploy that infrastructure.
5
+
---
6
+
7
+
# Stack configuration files
8
+
9
+
[Stacks](/terraform/language/stacks) use two types of configuration files to separate defining the components of your infrastructure from deployment details. Use a component configuration to define your infrastructure once, and a deployment configuration to deploy that infrastructure multiple times with different configurations.
10
+
11
+
## File types
12
+
13
+
A Stack configuration is made up of of two different file types:
14
+
15
+
- Component files, ending in `.tfcomponent.hcl`, declare the infrastructure components that this Stack creates and the input values of those components.
16
+
- Deployment files, ending in `.tfdeploy.hcl`, declare how many times to deploy a stack and the input values for each deployment.
17
+
18
+
### Component configuration files
19
+
20
+
Component files, ending in `.tfcomponent.hcl`, define the infrastructure components that make up your Stack. Component configuration files focus on what infrastructure you want to create, without specifying where or how many times to deploy it.
21
+
22
+
The component configuration replaces Terraform's traditional root module structure and declares which modules to include, how to configure providers, and what variables your Stack accepts. Each Stack requires at least one `component` block, and you must add a `component` block for every module you want to include in your Stack. Learn more about [writing a component configuration](/terraform/language/stacks/component/config).
23
+
24
+
You can define the following blocks in component configuration files:
25
+
26
+
- The [`component`](/terraform/language/block/stack/configuration/component) block sources individual modules that make up your Stack. Each component receives input variables and accepts providers that you declare at the Stack level.
27
+
- The [`required_providers`](/terraform/language/block/stack/configuration/required_providers) block declares which providers your component configuration requires so that Terraform can install and use them.
28
+
- The [`provider`](/terraform/language/block/stack/configuration/provider) block configures providers and passes that configuration to components.
29
+
- The [`removed`](/terraform/language/block/stack/configuration/removed) block defines components you want to remove from your Stack while ensuring proper cleanup of resources.
30
+
- The [`variable`](/terraform/language/block/stack/configuration/variable) block defines input variables that your deployments can set with different values.
31
+
- The [`output`](/terraform/language/block/stack/configuration/output) block defines values to expose in the HCP Terraform UI and to make available to deployments.
32
+
- The [`locals`](/terraform/language/block/locals) block defines local values that you can reference within your component configuration.
33
+
34
+
You can separate your component configuration into several files for easier navigability. For example, the following file structure separates a Stack's components from the other other blocks that help configure those components:
35
+
36
+
-`components.tfcomponent.hcl` - Defines your Stack's components
37
+
-`providers.tfcomponent.hcl` - Configures providers in this Stack
38
+
-`variables.tfcomponent.hcl` - Declares input variables in this Stack
39
+
-`outputs.tfcomponent.hcl` - Defines output values of this Stack
40
+
41
+
### Deployment configuration files
42
+
43
+
Deployment configuration files (`.tfdeploy.hcl`) define how HCP Terraform deploys your Stack's infrastructure. Deployment configuration files focus on where and how to deploy your infrastructure, using the components you defined in your component configuration.
44
+
45
+
Your Stack must have at least one `deployment` block. The deployment configuration file specifies how many deployments to create, what values to pass to each deployment, and how to orchestrate the deployment run process.
46
+
47
+
You can define the following blocks in deployment configuration files:
48
+
49
+
- The [`deployment`](/terraform/language/block/stack/deployment/deployment) block defines how many times you want to deploy your Stack's infrastructure and with what input values.
50
+
- The [`deployment_group`](/terraform/language/block/stack/deployment/deployment_group) block groups deployments together to configure shared settings and auto-approval rules.
51
+
- The [`deployment_auto_approve`](/terraform/language/block/stack/deployment/deployment_auto_approve) block defines rules that automatically approve deployment plans based on specific conditions.
52
+
- The [`identity_token`](/terraform/language/block/stack/deployment/identity_token) block defines JSON Web Tokens (JWT) that Terraform generates for OIDC authentication with cloud providers.
53
+
- The [`store`](/terraform/language/block/stack/deployment/store) block provides access to external secret stores and variable sets from your deployment configuration.
54
+
- The [`publish_output`](/terraform/language/block/stack/deployment/publish_output) block exports values from your Stack that other Stacks in the same project can consume.
55
+
- The [`upstream_input`](/terraform/language/block/stack/deployment/upstream_input) block consumes outputs from another Stack in the same project and uses them as inputs in your current Stack.
56
+
- The [`locals`](/terraform/language/block/locals) block defines local values that you can reference within your deployment configuration.
57
+
58
+
## File organization
59
+
60
+
HCP Terraform processes all the configuration files in your Stack's root directory, regardless of their names. You can organize your configuration across multiple files based on your preferences, similar to traditional Terraform configurations.
61
+
62
+
Both component configuration and deployment configurations must reside at the root level of your Stack repository. HCP Terraform automatically discovers and processes all `.tfcomponent.hcl` and `.tfdeploy.hcl` files in dependency order.
63
+
64
+
## Next steps
65
+
66
+
- Learn how to write [component configuration](/terraform/language/stacks/component/config) files
67
+
- Learn how to write [deployment configuration](/terraform/language/stacks/deploy/create) files
Copy file name to clipboardExpand all lines: content/terraform/v1.13.x/docs/language/stacks/component/config.mdx
+50-14Lines changed: 50 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,13 +13,27 @@ Your component configuration file defines multiple components that share a lifec
13
13
14
14
You declare the infrastructure that makes up your Stack in the component configuration file. Component configuration files replace Terraform’s traditional root module and serve as the blueprint for what your Stack deploys.
15
15
16
-
Component configuration files use a new file type, `tfcomponent.hcl`, to define everything that shares your Stack’s lifecycle. After writing your component configuration, you can write a deployment configuration to dictate how HCP Terraform deploys your Stack’s infrastructure.
16
+
Component configuration files use the `<NAME>.tfcomponent.hcl` file type, and define everything that shares your Stack’s lifecycle. After writing your component configuration, you can write a [deployment configuration](/terraform/language/stacks/deploy/config) to dictate how HCP Terraform deploys your Stack’s infrastructure.
17
17
18
-
As with Terraform configuration files, HCP Terraform processes all of the blocks in your component configuration and deployment configuration files in your Stack's root directory in dependency order. You can organize your component configuration into multiple files as in traditional Terraform configurations.
18
+
As with Terraform configuration files, HCP Terraform processes all of the blocks in your component configuration and deployment configuration files in your Stack's root directory in dependency order. You can organize your component configuration into multiple files, as in traditional Terraform configurations.
19
19
20
20
### Requirements
21
21
22
-
Before you begin writing your component configuration, ensure you have the `terraform-stacks-cli` for initializing and validating your component configurations. For installation guidance, refer to the [Stacks CLI reference](/terraform/language/stacks/reference/tfcomponents-cli).
22
+
Use Terraform v1.13.x or later to access the Stacks CLI plugin, and run `terraform stacks` CLI commands.
23
+
24
+
During the beta release, Stacks had a separate [Terraform Stacks CLI](/terraform/language/v1.12.x/stacks/reference/tfstacks-cli), which no longer supports current functionality.
25
+
26
+
## Create a version file
27
+
28
+
Begin by adding a `.terraform-version` file to your Stack's root directory to specify the Terraform version required for your Stack. For example, the following file specifies Terraform v1.13.0:
29
+
30
+
<CodeBlockConfigfilename=".terraform-version">
31
+
32
+
```hcl
33
+
1.13.0
34
+
```
35
+
36
+
</CodeBlockConfig>
23
37
24
38
## Define your component configuration
25
39
@@ -29,9 +43,9 @@ All of your Stack’s configuration files must use the `.tfcomponent.hcl` file t
29
43
30
44
The `component` block defines the pieces that make up your Stack. Add a `component` block for each top-level module you want to include in the Stack. Specify the source module, inputs, and providers for each component.
After establishing your top-level modules, you can use child modules without adding additional `component` blocks.
65
+
</CodeBlockConfig>
66
+
52
67
53
-
The component configuration file type accepts most classic Terraform configuration blocks but with some key differences. For more details on declaring providers in Stacks, refer to [Declare providers](/terraform/language/stacks/component/declare-providers). For more information on the component configuration file type and all the blocks and attributes it accepts, refer to the [Configuration file reference](/terraform/language/stacks/reference/tfcomponent).
68
+
After establishing your top-level modules, you can use child modules without adding additional `component`blocks.
54
69
55
70
The `component` block supports the `for_each` meta-argument if you need to replicate components across multiple instances. For example, the following configuration uses `for_each` to provision modules in multiple AWS regions for a given environment.
After writing your component configuration, use the Terraform Stacks CLI to validate it.
91
+
</CodeBlockConfig>
92
+
93
+
94
+
You can define the following blocks in component configuration files to configure your Stack's components:
95
+
96
+
- The [`component`](/terraform/language/block/stack/configuration/component) block sources individual modules that make up your Stack. Each component receives input variables and accepts providers that you declare at the Stack level.
97
+
- The [`required_providers`](/terraform/language/block/stack/configuration/required_providers) block declares which providers your component configuration requires so that Terraform can install and use them.
98
+
- The [`provider`](/terraform/language/block/stack/configuration/provider) block configures providers and passes that configuration to components.
99
+
- The [`removed`](/terraform/language/block/stack/configuration/removed) block defines components you want to remove from your Stack while ensuring proper cleanup of resources.
100
+
- The [`variable`](/terraform/language/block/stack/configuration/variable) block defines input variables that your deployments can set with different values.
101
+
- The [`output`](/terraform/language/block/stack/configuration/output) block defines values to expose in the HCP Terraform UI and to make available to deployments.
102
+
- The [`locals`](/terraform/language/block/locals) block defines local values that you can reference within your component configuration.
103
+
104
+
Provider authentication works differently for a Stack, for more details on declaring providers in Stacks, refer to [Declare providers](/terraform/language/stacks/component/declare-providers).
105
+
106
+
After writing your component configuration, you can validate your configuration locally using the Terraform CLI.
77
107
78
108
## Validate your configuration
79
109
80
-
Once you have finished your component configuration, use the `terraform-stacks-cli` tool to validate your configuration and generate the necessary provider lock files.
110
+
Once you have finished your component configuration, you can use [`terraformstacks` CLI](/terraform/cli/commands/stacks) commands to validate your configuration and generate the necessary provider lock files.
81
111
82
112
```shell-session
83
-
$ tfcomponents init
84
-
$ tfcomponents validate
113
+
$ terraform stacks init
114
+
$ terraform stacks validate
85
115
```
86
116
87
-
For installation guidance and more details, refer to the [Stacks CLI](/terraform/language/stacks/reference/tfcomponents-cli).
117
+
You can also re-format your configuration files using the `terraform fmt` command to ensure consistent styling:
118
+
119
+
```shell-session
120
+
$ terraform stacks fmt
121
+
```
88
122
89
123
## Next steps
90
124
91
125
If you have not yet defined the providers for your Stack, proceed to [Declare providers](/terraform/language/stacks/component/declare-providers). You can also learn how to [Authenticate your Stack](/terraform/language/stacks/deploy/authenticate) to ensure your providers are properly set up.
126
+
127
+
After completing your component configuration, the next step is to [define your deployment configuration](/terraform/language/stacks/deploy/config) to specify how you want to deploy your Stack's infrastructure.
0 commit comments