AcademyWorld Builder: Infrastructure as CodeDynamic Structures (Variables)

Module 3: Output Intel

When you build something in the cloud, you often need to know its ID or its address (URL) so you can use it in other systems.

Tactical Intel: Output Values

Outputs are like "return values" for your infrastructure. They tell Terraform: "After you're done building, tell me the exact ID of what you created."

Step 1: Defining the Output

We'll create another file to store our output requests.

Mission: Create a file named outputs.tf and add this code:

output "bucket_arn" {
  description = "The Amazon Resource Name of the bucket"
  value       = aws_s3_bucket.my_world.arn
}

Step 2: Extraction

When you run apply, Terraform will now print out this "Intel" at the very end of the process.

Mission: Run terraform apply -auto-approve and look for the Outputs: section at the bottom.

booting...

Tactical Insight: Intelligence Gathering

You can also see your outputs at any time without running a full build by typing: terraform output

Mission Control

Define an Output Value

Expected Command

grep 'output' outputs.tf

Extract the Data