Terraform
Component configuration overview
Component configuration files define the infrastructure components that make up your Stack. You write component configuration in .tfcomponent.hcl
files.
Background
In component configuration files, you declare what infrastructure components are part of your Stack. Each component sources a Terraform module and represents a reusable piece of infrastructure that you can provision and manage.
Your component configuration defines multiple components that share a lifecycle you can repeatedly deploy. This helps ensure consistency across environments and reduces the complexity of provisioning at scale.
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 defining Stack component configuration files.
Configuration blocks
You can define the following blocks in component configuration files:
- The
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. - The
required_providers
block declares which providers your component configuration requires so that Terraform can install and use them. - The
provider
block configures providers and passes that configuration to components. - The
removed
block defines components you want to remove from your Stack while ensuring proper cleanup of resources. - The
variable
block defines input variables that your deployments can set with different values. - The
output
block defines values to expose in the HCP Terraform UI and to make available to deployments. - The
locals
block defines local values that you can reference within your component configuration.