Kno*_*ing 6 terraform terraform-template-file
我在terraform中有这个代码:
data "archive_file" "lambdazip" {
type = "zip"
output_path = "lambda_launcher.zip"
source_dir = "lambda/etc"
source_dir = "lambda/node_modules"
source {
content = "${data.template_file.config_json.rendered}"
filename = "config.json"
}
}
Run Code Online (Sandbox Code Playgroud)
我这样做时会出现以下错误terraform plan:
* data.archive_file.lambdazip: "source": conflicts with source_dir
("lambda/node_modules")
* data.archive_file.lambdazip: "source_content_filename": conflicts
with source_dir ("lambda/node_modules")
* data.archive_file.lambdazip: "source_dir": conflicts with
source_content_filename ("/home/user1/experiments/grascenote-
poc/init.tpl")
Run Code Online (Sandbox Code Playgroud)
我使用的是terraform版本v0.9.11
@Ram 是正确的。您不能在同一块中使用source_dir和。sourcearchive_file
config_json.tpl
{"test": "${override}"}
Run Code Online (Sandbox Code Playgroud)
{"test": "${override}"}
Run Code Online (Sandbox Code Playgroud)
# create the template file config_json separately from the archive_file block
resource "local_file" "config" {
content = templatefile("${path.module}/config_json.tpl", {
override = "my value"
})
filename = "${path.module}/lambda/etc/config.json"
}
Run Code Online (Sandbox Code Playgroud)
# now you can grab the entire lambda source directory or specific subdirectories
data "archive_file" "lambdazip" {
type = "zip"
output_path = "lambda_launcher.zip"
source_dir = "lambda/"
}
Run Code Online (Sandbox Code Playgroud)
地形运行
data "template_file" "config_json" {
template = "${file("${path.module}/config_json.tpl")}"
vars = {
override = "my value"
}
}
# create the template file config_json separately from the archive_file block
resource "local_file" "config" {
content = "${data.template_file.config_json.rendered}"
filename = "${path.module}/lambda/etc/config.json"
}
Run Code Online (Sandbox Code Playgroud)
压缩文件内容
# now you can grab the entire lambda source directory or specific subdirectories
data "archive_file" "lambdazip" {
type = "zip"
output_path = "lambda_launcher.zip"
source_dir = "lambda/"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2357 次 |
| 最近记录: |