기본적인 형식

output "NAME" {
	 value = VALUE
}

output "cluster_id" {
	 value = module.eks.cluster_id
}

실습

provider "aws" {
  region = "ap-northeast-2"
}

resource "aws_instance" "my_instance" {
  ami = "ami-402d8157"
  instance_type = "t2.micro"
  tags = {
    Name = "Test"
  }
}

output "instance_id_addr" {
  value = aws_instance.my_instance.public_ip
}

output "instance_public_id" {
  value = aws_instance.my_instance.id
}

// EC2 인스턴스를 만드는 간단한 예제이다.
// terraform apply를 진행하면 add, change, destroy말고도 OutPuts: 하고 저 정보들이 나온다
// terraform.tfstate 파일에서도 확인 가능