Outputs
출력값 : TerraForm이 적용된 후에 사용자가 확인할 수 있는 값을 정의
다른 TerraForm 구성 or 모듈과의 연동 시 중요한 값을 출력하여 쉽게 참조할 수 있게 한다
정의
output "name" { ... }
예시
output "instance_id" {
description = "The ID of the created instance"
value = aws_instance.example.id
}
용도
- 생성된 리소스의 ID, IP와 같이 주요정보를 사용자가 쉽게 확인할 수 있게 제공
- 다른 구성이나 모듈에서 참조할 수 있도록 값 노출
- Terraform Apply 후 결과를 사용자에게 전달
Output에서 Array처럼 조회
정의
output "instance_ids" {
description = "The IDs of the created instances"
value = aws_instance.example[*].id
}
aws_instance.example[*].id
: 모든 생성된aws_instance
리소스의 ID를 배열로 반환- [*] : 모든 인덱스
'IaC👩💻 > TerraForm' 카테고리의 다른 글
[Terraform] 조건문 (0) | 2024.08.23 |
---|---|
[TerraForm] Count (0) | 2024.08.23 |
[TerraForm] Local (0) | 2024.08.23 |
[TerraForm] variable (0) | 2024.08.23 |
[Terraform] 리소스와 데이터 (0) | 2024.08.23 |