퍼블릭 클라우드
[Terraform] 테라폼 join 함수(function)
변군이글루
2021. 4. 17. 13:06
반응형
테라폼 join 함수(function)
: join은 주어진 구분 기호를 사용하여 주어진 문자열 목록의 모든 요소를 함께 연결하여 문자열을 생성합니다
instance 모듈
instance.tf 편집
$ vim instance.tf
...
###################################################
##################### OUTPUTS #####################
###################################################
output "server_id" {
value = join(", ", aws_instance.instance.*.id)
}
output "server_id" {
value = join(", ", aws_instance.instance.*.id)
}
instance 메인
main.tf 편집
$ vim main.tf
...
###################################################
##################### OUTPUTS #####################
###################################################
output "aws_webserver_id" {
description = "인스턴스 정보"
value = module.ec2-web.server_id
}
output "aws_webserver_id" {
description = "인스턴스 정보"
value = module.ec2-web.server_id
}
terraform apply
$ terraform apply
...
Outputs:
aws_webserver_id = "i-0cbcf7, i-0a4d89"
join - Functions - Configuration Language - Terraform by HashiCorp
The join function produces a string by concatenating the elements of a list with a given delimiter.
www.terraform.io
728x90
반응형