For this lab, there is this section:
All the resources for the
random provider can be recreated by using a
map type argument called
keepers. A change in the value will force the resource to be recreated.
This argument accepts arbitrary key/value pairs and in our example, it is set to the key called length whose value was updated from
12 in the
terraform apply now will destroy the current
random_string resource and then create a new one with the length that is
12 characters long.
What is the purpose of the keepers “map-type” argument? The prompt says that a change in the value will force the resource to be recreated and is set to the key called length. My question is, why do we need this at all? If the length variable changes then the resource will be recreated anyway. What is the purpose of this “keepers” key and what is the benefit? I wish there was some explanation as to map-type arguments or “keepers” in the lecture before showing us this in the lab.
I appreciate any help. Thank you.