- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想将 terraform 状态文件推送到 github 存储库。 Terraform 中的 file 函数无法读取 .tfstate 文件,因此我需要先将其扩展名更改为 .txt。现在为了自动化它,我创建了一个空资源,它有一个供应器来运行命令将 tfstate 文件复制为同一目录中的 txt 文件。我遇到了这个“depends_on”参数,它允许您指定在运行当前资源之前是否需要首先创建特定资源。但是,它不起作用,我立即收到错误消息,即“terraform.txt”文件在文件功能需要时未退出。
provider "github" {
token = "TOKEN"
owner = "USERNAME"
}
resource "null_resource" "tfstate_to_txt" {
provisioner "local-exec" {
command = "copy terraform.tfstate terraform.txt"
}
}
resource "github_repository_file" "state_push" {
repository = "TerraformStates"
file = "terraform.tfstate"
content = file("terraform.txt")
depends_on = [null_resource.tfstate_to_txt]
}
最佳答案
The documentation for the file
function解释这种行为:
This function can be used only with files that already exist on disk at the beginning of a Terraform run. Functions do not participate in the dependency graph, so this function cannot be used with files that are generated dynamically during a Terraform operation. We do not recommend using dynamic local files in Terraform configurations, but in rare situations where this is necessary you can use the
local_file
data source to read files while respecting resource dependencies.
local_file
数据源,来自
the hashicorp/local
provider , 将文件作为资源操作(在应用阶段)而不是作为配置加载的一部分读取:
resource "null_resource" "tfstate_to_txt" {
triggers = {
source_file = "terraform.tfstate"
dest_file = "terraform.txt"
}
provisioner "local-exec" {
command = "copy ${self.triggers.source_file} ${self.triggers.dest_file}"
}
}
data "local_file" "state" {
filename = null_resource.tfstate_to_txt.triggers.dest_file
}
resource "github_repository_file" "state_push" {
repository = "TerraformStates"
file = "terraform.tfstate"
content = data.local_file.state.content
}
terraform.tfstate
在 Terraform 运行时创建文件是一件非常不寻常的事情,并且很可能导致未定义的行为,因为 Terraform 可以在整个
terraform apply
中在不可预测的时刻重复更新该文件。 .
terraform.tfstate
文件。
关于地形 : depends_on argument not creating the specified resource first,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65678208/
示例:https://www.terraform.io/docs/providers/kubernetes/r/service_account.html 我们看到了: resource "kubern
示例:https://www.terraform.io/docs/providers/kubernetes/r/service_account.html 我们看到了: resource "kubern
我有 5 个 keyvaults,有 5 个 secret ,问题是我不希望我的 terraform 文件有 10 个这样的数据 block : data "azurerm_key_vault" "k
我之前在我的 TF 代码中使用过这个: count = "${var.whatever == "true" ? 1 : 0}" 这非常适合我想要使用的东西。但是,我正在考虑如何最好地使用类似于说的
我之前在我的 TF 代码中使用过这个: count = "${var.whatever == "true" ? 1 : 0}" 这非常适合我想要使用的东西。但是,我正在考虑如何最好地使用类似于说的
我想创建一个上面有山的地形,使用一个非常基本的原理,如这个高度映射所示: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
根据文档,使用terraform,我能够在 digital ocean 上创建一个小滴: resource "digitalocean_volume" "foobar" { region
在 Terraform 中,我正在尝试创建一个模块,其中包含一个带有变量键的 map 。我不确定这是否可能,但我尝试了以下但没有成功。 resource "aws_instance" "web" {
我正在使用Box2d进行自行车物理游戏,Box2d可以让你拥有8点或更少的凸多边形的固定装置,有人知道更简单的方法吗除了制作一大堆固定装置之外,还有复杂的凹形地形?或者这是唯一的方法? 任何想法、指示
我正在尝试在 LWJGL 中制作 2D 游戏。我在地形生成方面遇到问题。 我目前有一个生成地形的算法,但它总是随机的,我永远无法再次获得相同的世界,我想制作一个基于生成 x 和 y 坐标的算法给定的数
我在使用 libgdx 和 box2d 进行卡车游戏。 在我的游戏中 1 米 = 100 像素。 我的 2d 地形是由我生成的,由点组成。 我所做的是为整个多边形制作了一个多边形区域并使用了textu
我有一个 3D boolean 值数组,代表一些 3D 地形。目前我可以通过在数组中的 x y 和 z 指定的位置绘制一个点来绘制它,它看起来像这样。 我想不通的是如何使用三角形绘制它,所以它看起来像
我读过很多关于这个概念的教程,但我觉得它们都没有深入探讨如何做到这一点。我已经知道 3D 编程(光栅化、投影矩阵等)、光线转换(使用欧几里得几何和矢量)和光线追踪如何工作,我只需要知道如何使用柏林噪声
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 9 年前。 Improve this qu
我正在做一些地形渲染,但遇到了一些麻烦。在这个时间点,我只是镶嵌顶点补丁,然后用高度图替换它们。我目前的问题是渲染看起来很时髦。我已经调试了一段时间,看起来这是深度缓冲区的问题。除此之外,我对正在发生
在 OpenGL 中用四边形制作地形纹理的最佳方法是什么?我有大约 30 种不同的纹理我想为我的地形(每种地形类型 1 个纹理,所以 30 种地形类型)并且希望在任何两个地形之间平滑过渡。 我一直在浏
执行时 terraform plan我没有错误,但是当我执行 terraform apply 时我收到以下错误。 地形计划输出:- + aws_route53_record.alm_route_rec
执行 terraform init 时出现以下错误升级到 0.12.2 后的命令版本。早期的相同代码在 terraform 中运行良好,没有问题 0.11.10版本。 alb.tf tags {
terraform init成功初始化但卡在 terraform 计划上。 该错误与功能块有关。我不确定在哪里添加功能块: Insufficient features blocks (source c
我正在使用 terraform 版本 0.14.3。我有一个用于创建 Azure 网络接口(interface)卡的模块,如下所示: resource "azurerm_network_interfa
我是一名优秀的程序员,十分优秀!