0
0
Terraformcloud~5 mins

Sensitive output values in Terraform - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Sensitive output values
O(n)
Understanding Time Complexity

We want to understand how marking output values as sensitive affects the time it takes Terraform to run.

Specifically, how does this choice impact the number of operations Terraform performs?

Scenario Under Consideration

Analyze the time complexity of marking outputs as sensitive in Terraform.

output "db_password" {
  value     = aws_db_instance.example.password
  sensitive = true
}

output "db_endpoint" {
  value = aws_db_instance.example.endpoint
}

This code marks the database password output as sensitive, hiding it from normal display, while the endpoint is shown normally.

Identify Repeating Operations

Terraform reads and processes each output value during plan and apply.

  • Primary operation: Reading and optionally masking output values.
  • How many times: Once per output defined in the configuration.
How Execution Grows With Input

As the number of outputs increases, Terraform processes each output once.

Input Size (n)Approx. Api Calls/Operations
1010 output processing steps
100100 output processing steps
10001000 output processing steps

Pattern observation: The work grows directly with the number of outputs.

Final Time Complexity

Time Complexity: O(n)

This means the time to process outputs grows linearly with how many outputs you have.

Common Mistake

[X] Wrong: "Marking outputs as sensitive makes Terraform run much slower because it hides values."

[OK] Correct: Marking outputs sensitive only changes display behavior; Terraform still processes each output once, so the time grows linearly, not slower or faster.

Interview Connect

Understanding how output configurations affect Terraform's work helps you design efficient infrastructure code and explain your choices clearly.

Self-Check

"What if we added many outputs that are all marked sensitive? How would that affect the time complexity?"