Amazon web services 如何在使用terraform创建新版本时保留旧的aws ecs taskdefinition版本

Amazon web services 如何在使用terraform创建新版本时保留旧的aws ecs taskdefinition版本,amazon-web-services,terraform,terraform-provider-aws,Amazon Web Services,Terraform,Terraform Provider Aws,我正在使用terraform创建ecs任务定义 resource "aws_ecs_task_definition" "tktest_terraform-td" { family = "nodejs-webapp" container_definitions = "${templatefile("${path.module}/taskdefinition/service-td.tpl", { web

我正在使用terraform创建ecs任务定义

resource "aws_ecs_task_definition" "tktest_terraform-td" {
  family = "nodejs-webapp"
  container_definitions = "${templatefile("${path.module}/taskdefinition/service-td.tpl", { webapp_docker_image = "${var.webapp_docker_image_name}:${var.webapp_docker_image_tag}"})}"
}
当任务定义发生更改时,会创建一个新版本,但问题是旧版本会被删除


是否可以创建一个新版本,但同时保留旧版本?

这是一个长期存在的问题,任务定义已在上进行了记录和讨论

到目前为止,问题尚未解决,报告的解决方法是手动从TF状态中删除任务的当前版本。在您的情况下,它将是:

# we can still get the task definition diff at this point, which we care about
terraform plan

# remove from state so that task definition is not destroyed, and we're able to rollback in the future if needed
terraform state rm aws_ecs_task_definition.tktest_terraform-td

# diff will show a brand new task definition created, but that's ok because we got the diff in step 1
terraform apply

你有任何代码可以证明这个问题吗?@Marcin在上面用代码进行了更新