0
0
Terraformcloud~10 mins

Output values after apply in Terraform - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Output values after apply
Write Terraform config with outputs
Run terraform init
Run terraform apply
Terraform creates resources
Terraform shows output values
User sees output values on screen
Terraform config defines outputs, then after apply, Terraform creates resources and shows output values to the user.
Execution Sample
Terraform
resource "aws_s3_bucket" "example" {
  bucket = "my-example-bucket"
}

output "bucket_name" {
  value = aws_s3_bucket.example.bucket
}
Creates an S3 bucket and outputs its name after apply.
Process Table
StepActionTerraform StateOutput Value Shown
1Write config with resource and outputNo resources createdNo output yet
2Run terraform initProviders initializedNo output yet
3Run terraform applyResource aws_s3_bucket.example createdNo output yet
4Terraform finishes applyState updated with bucket infobucket_name = "my-example-bucket"
5User sees output on screenState stablebucket_name = "my-example-bucket"
💡 Terraform apply completes and outputs are displayed to user.
Status Tracker
VariableStartAfter ApplyFinal
aws_s3_bucket.example.bucketundefined"my-example-bucket""my-example-bucket"
output.bucket_nameundefined"my-example-bucket""my-example-bucket"
Key Moments - 2 Insights
Why don't output values show before running 'terraform apply'?
Output values depend on resource attributes created during apply, so before apply, these values are undefined as shown in execution_table step 1 and 3.
Can output values change after apply without changing config?
Yes, if resource attributes change (like bucket name), output values update after next apply, reflecting new state as in execution_table step 4.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step does Terraform show the output value?
AStep 2
BStep 1
CStep 4
DStep 3
💡 Hint
Check the 'Output Value Shown' column in execution_table rows.
According to variable_tracker, what is the value of 'output.bucket_name' before apply?
Aundefined
B"my-example-bucket"
Cnull
Dempty string
💡 Hint
Look at the 'Start' column for 'output.bucket_name' in variable_tracker.
If the bucket name changes in config and you run apply again, what happens to the output value?
AOutput value stays the same
BOutput value updates to new bucket name
CTerraform errors out
DOutput value becomes undefined
💡 Hint
Refer to key_moments about output values changing after apply.
Concept Snapshot
Terraform outputs show resource info after apply.
Define outputs in config with 'output' blocks.
Run 'terraform apply' to create resources.
Outputs appear after apply completes.
Outputs reflect current resource state.
Full Transcript
This visual execution shows how Terraform outputs work. First, you write a config with resources and output blocks. Then you run 'terraform init' to prepare. Next, 'terraform apply' creates resources. After apply finishes, Terraform updates its state and shows output values on screen. Outputs depend on resource attributes created during apply, so they are undefined before apply. If resource attributes change, outputs update after next apply. This helps you see important info like resource names or IPs after deployment.