In this Video we are going to cover Terraform Output Variables Example | Terraform Output Values
#terraformoutputvariables #terraformoutputvalues #terraformtutorial
0:00 Introduction to Terraform output Values
6:25 How to use output.tf in Terraform
9:41 How to Stop printing sensitive value in terraform output
Follow below code for How to Terraform Output Values
Syntax of output variables/values:
output "output_value"{
value = "welcome to devopshint"
}
1. Without output.tf - main.tf
In this example we use only main.tf for print output values
Example of without output.tf
main.tf
provider "aws" {
region = "ap-south-1"
}
resource "aws_instance" "web" {
ami = "ami-0c1a7f89451184c8b"
instance_type = "t2.micro"
key_name = "Dev-UbuntuKey"
tags= {
Name = "terraform demo"
}
}
output "output_values"{
value = "welcome to devopshint"
description = "This is output values"
}
2. output.tf
In this example we can create output.tf file for printing public_dns
Example of output values/ variables with output.tf
main.tf
provider "aws" {
region = "ap-south-1"
}
resource "aws_instance" "web" {
ami = "ami-0c1a7f89451184c8b"
instance_type = "t2.micro"
key_name = "Dev-UbuntuKey"
tags= {
Name = "terraform demo"
}
}
output.tf
output "public_dns"{
value = aws_instance.web.public_dns
description = "this is output values"
}
3. Sensitive
In this example we can hide some sensitive data if user don’t want to show personal data to public in that time we can use sensitive = true
Example of sensitive values in terraform
main.tf
provider "aws" {
region = "ap-south-1"
}
resource "aws_instance" "web" {
ami = "ami-0c1a7f89451184c8b"
instance_type = "t2.micro"
key_name = "Dev-UbuntuKey"
tags= {
Name = "terraform demo"
}
}
output.tf
output "public_dns"{
value = aws_instance.web.public_dns
description = "this is output values"
sensitive = true
}
Related Articles:
How to Use Visual Studio code for Terraform | Creating EC2 Instance using Terraform
https://www.youtube.com/watch?v=hmKC6YagHqY
Lab #3 [Scenario-1]: How to Create VPC using Terraform | AWS VPC using Terraform | AWS Terraform
https://www.youtube.com/watch?v=LSz9VbdCPR0
If you likes our video, please subscribe our channel on YouTube Channel
null
1 Comments