티스토리 뷰

반응형

2. format

1. String 연결 방법인 format 사용법

  1. format 유형

foramt은 string 형식의 variable이나 tpye을 연결이 가능하게 합니다.

typing을 하게 되면 가능하지만, 변수를 연결을 하고자 할때 사용을 하면 유용하게 사용이 가능합니다.

예시) main.tf 내용

variable "name" {
  description = "input your name"
  type        = string
  default     = "sdh"
}

output "format_test" {

    value=format("%s-test-%s", "format", var.name)

}

결과를 확인하면 어떻게 나올까요?

결과 확인

$ terraform apply

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

format_test = "format-test-sdh"

설정한 것처럼, 이름이 format되어 확인이 되는걸 확인 할 수 있습니다.

반응형
댓글
반응형
최근에 올라온 글
Total
Today
Yesterday