【发布时间】:2021-08-22 11:26:28
【问题描述】:
我在 azure blob 存储帐户中有 terraform 状态,我在我的 jenkins 管道中引用了这个 terraform 状态。
我正在使用 terraform init 命令,该命令通过使用“-backend-config”参数在 blob 存储中引用此 terraform 状态,如下所示。
terraform init -input=false \
-backend-config="resource_group_name=RESOURCE_GROUP_NAME" \
-backend-config="storage_account_name=STORAGE_ACCOUNT_NAME" \
-backend-config="container_name=CONTAINER_NAME" \
-backend-config="key=STATE_FILE_NAME"
之后我正在运行 terraform plan 命令,该命令将其数据写入 terraform 状态,该状态处于 azure blob 存储中,我可以看到该文件正在 blob 存储帐户中更新。
但是,当我运行 terraform apply 命令时,它会在本地寻找其 terraform 状态,而我的 jenkins 管道正在失败。
因此,我尝试提供相同的 terraform 状态文件名,该文件名位于 azure blob 存储中,但仍然失败,因为它正在 jenkins 管道中本地查找此文件。 因此,想检查如何强制执行我的 terraform apply 命令以默认从 azure blob 存储获取其 terraform 状态文件,例如 terraform plan 命令会自动从 azure blob 存储引用它的 terraform 状态文件?
【问题讨论】:
标签: jenkins-pipeline terraform terraform-provider-azure