Writing your first vect project, part 4
In this part we give the project a shared value, a piece of data, and a secret, and watch vect keep the secret out of what it prints. We pick up in the vect-tutorial folder from Part 3, with the Temporal dev server still running and VECT_CONFIG still set.
Where to get help: open an issue on the issue tracker.
Run every command from inside vect-tutorial. The pet and greeting from Part 3 are still applied, and we change them in place. Pet names in this part will differ from yours.
What we’re adding
Three things, each a different way for a value to reach an executor:
- A global: a typed value declared once at the root and visible in every stack without being passed through
variables. We use one for the greeting word. - A
data "value"block: a data source that reads nothing and hands back the value you give it. It’s the simplest data source, and it’s referenced the same way as the ones that read from AWS or an HTTP endpoint. We use it for the sign-off. - A sensitive value: a password generated by the
petroot that flows intogreetingwithout ever being printed.
A secret in the pet root
Add a password to roots/pet/main.tf. The output is marked sensitive, as it would be in any Terraform root:
terraform {
required_providers {
random = {
source = "hashicorp/random"
version = "~> 3.6"
}
}
}
resource "random_pet" "this" {
length = 2
}
output "name" {
value = random_pet.this.id
}
resource "random_password" "token" {
length = 12
}
output "token" {
value = random_password.token.result
sensitive = true
}sensitive = true you already know, and it’s where we declare the secret. vect reads the mark from the root’s output and carries it along: through stack outputs and variables, into the next root’s inputs, and into what vect prints. You don’t repeat sensitive in the vect files.Take the secret in the greeting root
greeting takes three more variables: the greeting word, the sign-off, and the token. It uses the token only to make a receipt, a hash of it, so the root can show something about the secret without exposing it:
variable "greeting" {
type = string
}
variable "name" {
type = string
}
variable "signoff" {
type = string
}
variable "token" {
type = string
sensitive = true
}
resource "terraform_data" "greeting" {
input = "${var.greeting}, ${var.name}! ${var.signoff}."
}
resource "terraform_data" "receipt" {
input = sha256(var.token)
}
output "message" {
value = terraform_data.greeting.output
}
output "receipt" {
value = terraform_data.receipt.output
sensitive = true
}Wire it through the stacks
The pet stack now exports the token as well as the name:
executor "terraform" "pet" {
source = "../../roots/pet"
}
output "name" {
value = terraform.pet.name
}
output "token" {
value = terraform.pet.token
}The greeting stack takes the new inputs and passes them to its root. Notice greeting = greeting: a global is available in every stack as a bare name, with no variable to declare.
variable "name" {
type = string
}
variable "signoff" {
type = string
}
variable "token" {
type = string
}
executor "terraform" "greeting" {
source = "../../roots/greeting"
inputs = {
greeting = greeting
name = var.name
signoff = var.signoff
token = var.token
}
}
output "message" {
value = terraform.greeting.message
}
output "receipt" {
value = terraform.greeting.receipt
}The root declares the global and the data, and connects the stacks. Replace main.hcl:
global "greeting" {
type = string
value = "Hello"
}
data "value" "signoff" {
value = "See you soon"
}
stack "pet" {
source = "./stacks/pet"
}
stack "greeting" {
source = "./stacks/greeting"
name = stack.pet.name
signoff = data.value.signoff.value
token = stack.pet.token
}
output "message" {
value = stack.greeting.message
}
output "receipt" {
value = stack.greeting.receipt
}A global with a value is a composed global: its value is an expression. Without a value it’s an input global, which you supply when you run, with --global or a fact file. data.value.signoff.value reads the value attribute of the data block, the one attribute every value block has.
Validate and look at the graph:
vect validateSuccess!
(root) 0 blocks
stack.greeting 1 block
stack.pet 1 blockvect graphdata.value.signoff
stack.greeting.var.signoff
stack.pet.terraform.pet
stack.pet.output.name
stack.greeting.var.name
stack.pet.output.token
stack.greeting.var.token
stack.greeting.terraform.greeting
stack.greeting.output.message
output.message
stack.greeting.output.receipt
output.receiptdata.value.signoff is a node like any other, and it comes first. The token travels pet, output.token, var.token, greeting. The global isn’t a node: it’s bound everywhere, so nothing waits for it.
Plan and apply
vect planstack.pet.terraform.pet: running
stack.pet.terraform.pet: planned will run
stack.greeting.terraform.greeting: running
stack.greeting.terraform.greeting: deferred unknown inputs: inputs.token
plan of workspace "dev": succeeded (run 01a1e76c-311b-772b-8a95-21639d3ced06)
stack.greeting.terraform.greeting defer unknown inputs: inputs.token
stack.pet.terraform.pet run will runThe pet is will run, because its root gained a resource, and greeting is deferred again, since its token isn’t known yet. In the engine’s own output the password is already redacted. These are the lines that mention it:
+ bcrypt_hash = (sensitive value)
+ result = (sensitive value)
+ token = (sensitive value)vect applystack.pet.terraform.pet: running
stack.pet.terraform.pet: applied will run
stack.greeting.terraform.greeting: running
stack.greeting.terraform.greeting: applied will update
apply of workspace "dev": succeeded (run 01a1e76c-4142-7084-b336-bfef0808bdcf)
stack.greeting.terraform.greeting applied (update) will update
stack.pet.terraform.pet applied (run) will run
deployment pointer 5 appendedgreeting was applied (update): its inputs changed, so it was updated in place. Neither node asked for approval, since nothing was destroyed. The engine’s output for this run includes the sensitive outputs, and they print redacted:
stack.pet.terraform.pet | token = <sensitive>
stack.greeting.terraform.greeting | receipt = <sensitive>Read the outputs
Here are all the forms of vect output, each with what it printed. Your pet name and digest will differ.
$ vect output
message = "Hello, honest-eagle! See you soon."
receipt = redacted(string)
$ vect output receipt
redacted(string)
$ vect output --format json
{
"format_version": 1,
"workspace": "dev",
"outputs": {
"message": {
"value": "Hello, honest-eagle! See you soon.",
"sensitive": false
},
"receipt": {
"value": null,
"sensitive": true
}
},
"bundle_digest": "sha256:f1559ba2c747b207337a2bddfd81d6de9db36e3b527c2ebc53c5cc72e8a16253",
"applied_at": "2026-11-17T02:53:15.204229Z"
}
$ vect output --show-sensitive
message = "Hello, honest-eagle! See you soon."
receipt = "8049acb88f1297aa6a21a380e2f6901c8f63eb378e5146ee8ad59b47f4b500ff"
By default vect output prints redacted(string) for a sensitive value, and the JSON form says "sensitive": true with a null value.
--show-sensitive prints the real value. It’s a deliberate, separate switch, and against a shared server it needs a permission, workspace.read_sensitive_outputs, that most people won’t have. Running on your own machine, you have it. The value shown is the receipt, a hash of the token, so even the revealed value isn’t the secret itself.
The secret stays marked inside vect
vect inspect --observe <executor> evaluates the configuration against what is in Inventory, so you can see what greeting would be given. The token is there, still marked:
vect inspect --observe stack.pet.terraform.petThe output has a node for each executor. This is the inputs of the greeting node:
inputs = {
greeting = "Hello"
name = "honest-eagle"
signoff = "See you soon"
token = redacted(string)
}The name is a real value, read back from the applied pet. The token prints as redacted(string).
.vect/data/ holds it in plain text, just as Terraform’s local state does. Treat .vect/ as sensitive and don’t commit it.What we’ve done
A global, a data block, and a secret now reach greeting three different ways. The secret was generated by one root, handed to another, and shown redacted in vect output and vect inspect, and in the engine output vect passes through. In Part 5 we change an input, rename an executor safely, and tear everything down.