-
Notifications
You must be signed in to change notification settings - Fork 9.9k
create_before_destroy
behavior on count
/for_each
resources is not clearly documented
#37002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @geekofalltrades, The Rather than artificially linking |
We thought that it was, and I don't think that was an unreasonable conclusion to reach. resource "aws_instance" "foo" {
for_each = toset(["a", "b"])
# ...
lifecycle {
create_before_destroy = true
}
} The configuration structure groups these resources together into a collection, with the At least some
It sounds like A paragraph in the lifecycle docs about how |
Yes, you can reference an expanded resource like The behavior of Maybe to put it another way, a "resource" has no lifecycle, it is just a configuration object. Only resource instances have a lifecycle of some sort for Terraform to manage. I think a lot of users automatically insert the word "instance" or "object" wherever it's needed when the context requires talking about the managed object vs the configuration. The |
Terraform Version
Terraform v1.4.2 on darwin_arm64 + provider registry.terraform.io/hashicorp/aws v4.67.0 Your version of Terraform is out of date! The latest version is 1.11.3. You can update by downloading from https://www.terraform.io/downloads.html
Affected Pages
What is the docs issue?
The behavior of
create_before_destroy
on a resource collection type usingcount
orfor_each
isn't clear from documentation. There are two ways it could be interpreted to behave:create_before_destroy
is applied to each separately. If a plan wants to both add and delete resources with separatefor_each
keys orcount
indices from the collection, the creates and destroys happen in an undefined order.create_before_destroy
applies to the collection as a whole. If a plan wants to both add and delete resources with separatefor_each
keys orcount
indices from the collection, all resources to add will be created before any resources to remove are destroyed.We had a brief production outage because we assumed the latter, but we think we observed the former. The docs do not make it clear which behavior to expect.
Proposal
Explicitly document how
create_before_destroy
and maybelifecycle
arguments in general are applied to resources in a collection and whether any of them apply to the collection as a whole.References
No response
The text was updated successfully, but these errors were encountered: