Jam*_*ams 1 terraform aws-batch terraform-provider-aws
我使用 Terraform 建立了基础设施,包括批处理服务作业队列、计算环境和作业定义。
对 Terraform 进行更改后,我运行terraform apply并收到以下错误:
Error: error deleting Batch Compute Environment (data-load): : Cannot delete, found existing JobQueue relationship
status code: 400, request id: 25449415-9c36-4748-95e6-925647bd716a
Run Code Online (Sandbox Code Playgroud)
作业队列中没有作业。我假设它将与与批处理服务相关的其他资源一起被删除/替换,而不是在替换时暂停计算环境的显示。
在过去,我能克服这个问题的唯一方法是破坏我的状态文件并重新开始,但我认为一定有更好的方法。我怎样才能解决这个问题?
小智 5
当在 Terraform 中重新创建资源时,默认情况下会按顺序删除并创建资源。所以如果compute_environment_name你只改变并应用,作业队列所依赖的计算环境暂时不存在,所以你会死掉如下。错误:应用计划时出错:
1 error(s) occurred:
* aws_batch_compute_environment.sample (destroy): 1 error(s) occurred:
* aws_batch_compute_environment.sample: error deleting Batch Compute Environment (sample): : Cannot delete, found existing JobQueue relationship
Run Code Online (Sandbox Code Playgroud)
因此,compute_environment_name更改create_before_destroy = true并显式指定生命周期。
resource "aws_batch_compute_environment" "sample" {
compute_environment_name = "sample-v2"
...
instance_type = [
"m5",
]
...
lifecycle {
create_before_destroy = true
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2399 次 |
| 最近记录: |