Search⌘ K
AI Features

Outputting Resource Properties

Explore how to use Terraform outputs to display key resource properties, such as an S3 bucket name and ARN, after your Terraform run completes. Understand how to define outputs and see them in your project outputs. Practice creating and destroying resources while managing output data effectively.

The first example is pretty basic and, in the real world, probably not very useful. Outputs are much more useful when used to output the values of resources that have been created as part of a Terraform run.

Terraform output project example

Let’s create another Terraform project and output the values of resources as a part of a Terraform run:

C++
provider "aws" {
region = "us-east-2"
}
resource "aws_s3_bucket" "first_bucket" {
bucket = "kevholditch-bucket-outputs"
}
output "bucket_name" {
value = aws_s3_bucket.first_bucket.id
}
output "bucket_arn" {
value = aws_s3_bucket.first_bucket.arn
}
output "bucket_information" {
value = "bucket name: ${aws_s3_bucket.first_bucket.id}, bucket arn: ${aws_s3_bucket.first_bucket.arn}"
}

Let’s walk through the above code.

  • The provider and resource should be familiar to you. We are simply ...