Next, we will create the terraform/outputs.tf file. This is the final step in building the core infrastructure. The purpose of this file is to define the output values that Terraform displays after the deployment is complete.
When Terraform finishes provisioning the infrastructure on AWS, it creates many resources with automatically generated values. For example:
Instead of opening the AWS Management Console and manually navigating through each service to locate and copy these values, the outputs.tf file instructs Terraform to display all important information directly in the terminal after the deployment is complete. This makes it much easier to retrieve the information needed for the next configuration steps or to quickly access the Web Dashboard.
# Cost data storage bucket
output "cost_data_bucket_name" {
description = "Name of the S3 bucket storing cost data"
value = aws_s3_bucket.cost_data.id
}
output "cost_data_bucket_arn" {
description = "ARN of the S3 bucket"
value = aws_s3_bucket.cost_data.arn
}
# Amazon SNS
output "sns_topic_arn" {
description = "ARN of the SNS topic for sending alerts"
value = aws_sns_topic.cost_alerts.arn
}
# Amazon SQS
output "sqs_events_queue_url" {
description = "URL of the main SQS queue"
value = aws_sqs_queue.events.url
}
output "sqs_dlq_url" {
description = "URL of the Dead Letter Queue"
value = aws_sqs_queue.dlq.url
}
# Lambda functions and scheduling
output "collector_role_arn" {
description = "ARN of the IAM role for the Lambda Collector"
value = aws_iam_role.collector.arn
}
output "schedule_rule_name" {
description = "Name of the EventBridge scheduling rule"
value = aws_cloudwatch_event_rule.schedule.name
}