Terraform-常见函数:文件操作函数

时间:2023-11-01 16:16:29

文件操作函数

表7 文件操作函数

函数名称

函数描述

样例

运行结果

abspath

计算文件的绝对路径

abspath("./hello.txt")

/home/demo/test/terraform/hello.txt

dirname

计算字符串中包含的路径

dirname("foo/bar/baz.txt")

foo/bar

basename

计算字符串中的文件名

basename("foo/bar/baz.txt")

baz.txt

file

读取文件并返回文件内容

file("./hello.txt")

Hello, cloud!

filebase64

读取文件并返回文件内容的base64编码

filebase64("./hello.txt")

SGVsbG8sIGNsb3VkIQ==

support.huaweicloud.com/basics-terraform/terraform_0005.html