Reputation: 1716
Is there a way to force terraform to keep creating new ECS Task definitions each time I change the task definition rather than destroying and creating a new one?
This is my config
resource "aws_ecs_service" "app-service" {
name = "my-task"
cluster = "${aws_ecs_cluster.app-cluster.id}"
task_definition = "${aws_ecs_task_definition.app-td.arn}"
desired_count = "${var.task_count}"
}
resource "aws_ecs_task_definition" "app-td" {
family = "my-task"
container_definitions = "${file("task_definition.json")}"
}
Upvotes: 2
Views: 2996
Reputation: 390
If you pass the skip_destroy=true
argument it will keep the old versions in AWS however, from the terraform plan it will still look to be a destroy and create when new changes are made but it will still be in the AWS UI.
resource "aws_ecs_task_definition" "app-td" {
family = "my-task"
container_definitions = "${file("task_definition.json")}"
skip_destroy = true
}
Upvotes: 2
Reputation: 989
Maybe I don't understand your question completely. But terraform keeps a tfstate file to associate specific aws instances with your definitions. Wouldn't removing the tfstate file simply force terraform to create new ones?
Upvotes: 0
Reputation: 301137
By the way Terraform works - this is not possible. If sees a resource has been changed, then it will either update it or recreate it based on what changed.
Upvotes: 2