I had an
aws_ecs_cluster (inside of a module) set up named “foo” and then used the same module later to set up another cluster. It also named the
aws_ecs_cluster as “foo” but other pieces failed because of pre-existing names. Note that these two module instances were in different workspaces/state files. Now I know that the
aws_ecs_cluster resource does not care if there is already an existing cluster of the same name - it will happily report that it has created the cluster and record that in the state file.
So, now I have the same
aws_ecs_cluster resource in two different state files. I do some work on my module so that it names the cluster based on the environment that I want it for so that now my second instance of this module will name the
aws_ecs_cluster as “foo-staging”. A plan now shows, however, that the original
aws_ecs_cluster.foo is deposed and will be destroyed because I have renamed the resource. I don’t want it to destroy that resource because it is actually the same resource that my original state file is tracking. So, I had to go in an edit the state file to just remove that deposed resource.