Terraform Cloud Simplifies Reusable Variable Management
HashiCorp Terraform Cloud variable sets let you simplify the management of reusable variables across an entire organization — the feature is now generally available.
A few months ago, we released a public beta of a brand-new way to consistently manage variables across workspaces in a Terraform Cloud organization. The response has been amazing. We have received substantial feedback containing creative use cases and helpful suggestions, and noticed a general buzz of excitement. Since the beta release, we have been continuously working to improve and incorporate that feedback.
With that in mind, we are now happy to announce the general availability of variable sets for HashiCorp Terraform Cloud and Terraform Enterprise.
» Terraform Cloud Variable Sets
Variable sets allow Terraform Cloud users to reuse both Terraform-defined and environment variables in an efficient and centralized way. Organization owners can create variable sets, populate the associated variables, and assign them to specific workspaces or across the entire organization. As values for those associated variables change, they will be updated in real-time. This greatly reduces the management overhead when updating variables, such as credentials, used across several workspaces.
Variable sets also reduce complexity for workspace owners and administrators. Previously, you would have to create individual variables on a per workspace basis. Now, you can create your workspace and simply apply one or more variable sets to streamline the process of provisioning resources. Those newly created workspaces already have variables defined, and there is a detailed order of precedence available in the Terraform documentation.
» TFE Provider Support
The public beta phase of variable sets offered a well-documented API to automate the workflow for managing variable sets and their associated variables. A consistent theme throughout the feedback was adding support for variable sets to the TFE provider. We are happy to announce that version 0.30 of the TFE provider now supports variable sets. The TFE provider now offers a new resource and data source for variable sets. The variable resource also now supports the variable set argument.
The code sample below shows an example of creating a new variable set and assigning a variable to that variable set:
# Create variable set “prod_infra”
resource "tfe_variable_set" "prod_infra" {
name = “prod infra”
description = “variables for azure infrastructure”
global = false
organization = data.tfe_organization.azure_prod.name
workspaces = [tfe_workspace.webapp_prod.id,...]
}
# Create variable "azure_subscription_id" and assign to variable set “prod_infra”
resource "tfe_variable" "azure_subscription_id" {
name = “subscription_id”
value = “xxxxxx-xxxx-xxxx-xxxx-xxxxxx”
organization = data.tfe_organization.azure_prod.name
category = "terraform"
variable_set = tfe_variable_set.prod_infra.id
}
» Get Started with Variable Sets
Variable sets are available for users of every tier on Terraform Cloud. Documentation on variable sets is available here: Managing Variables in Terraform Cloud. The TFE provider has also been updated to add support for variable sets.
Terraform Cloud is free to try, and organizations can upgrade to the Team & Governance or Business tiers at any time. To get started with Terraform Cloud, sign up and follow our Get Started with Terraform Cloud tutorial. To get started with variable sets, check out our new HashiCorp Learn guide: Manage Variable Sets in Terraform Cloud.
Sign up for the latest HashiCorp news
More blog posts like this one
New Terraform integrations with Crowdstrike, Datadog, JFrog, Red Hat, and more
12 new Terraform integrations from 9 partners provide more options to automate and secure cloud infrastructure management.
Terraform delivers launch-day support for Amazon S3 Tables, EKS Hybrid Nodes, and more at re:Invent
The Terraform provider for AWS now enables users to manage a variety of new services just announced at re:Invent.
HashiCorp at re:Invent 2024: Infrastructure Lifecycle Management with AWS
A recap of HashiCorp infrastructure news and developments on AWS from the past year, from a new provider launch to simplifying infrastructure provisioning and more.