Yes I am aware this is a duplicate of https://github.com/hashicorp/terraform/issues/3116, but there has been no update in quite some time, and that issue has been locked.
Currently trying to prevent an EBS volume from being destroyed on destruction of the rest of the state.
Example of what I'm trying to acomplish:
resource "aws_ebs_volume" "kafka-logs" {
count = "${var.kafka_count}"
availability_zone = "${element(aws_instance.kafka.*.availability_zone, count.index)}"
size = 500
tags {
Name = "kafka${count.index}"
}
lifecycle {
prevent_destroy = "${var.productioncluster}"
}
}
On non-production clusters (dev,staging, etc.) there is no need to store the EBS after the destruction of the environment since that data is not needed, but for a production environment I'd like to store off that EBS for later use if need.
Currently using Terraform v0.11.3
Sorry if it was inappropriate to create this issue, just curious as to if there are other solutions to this kind of problem, and if there has been any progress with implementing variables in lifecycle blocks.
Thanks for all the awesome work terraform team!
Having this would be such a huge advantage. It would allow me to sleep safely at night, knowing that the dev networks can be pulled down easily but the prod ones can't.
Hi @Asara,
I share your frustration, but I assure you that the we well aware of the issue and it remains on our radar to address. There are fundamental reasons in terraform that interpolation cannot happen in certain parts of the configuration, so unfortunately "just implementing" it isn't as easy as it sounds.
We have major changes to the configuration layer planned over the next couple releases, which will pave the way for us to be able to better address issue like this.
@jbardin thanks for the update friend.
This is just a longstanding issue and I was hoping to get some insight into progress. I personally have not thought of a good way to handle a situation such as mine other than manually editing the terraform state to remove the EBS, and that is not something I can do in an automated fashion.
Looking forward to future releases, and as always, thanks!
It looks like the discussion here has concluded, so since this is a duplicate of #3116 I'm going to close this out just to consolidate.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
Having this would be such a huge advantage. It would allow me to sleep safely at night, knowing that the dev networks can be pulled down easily but the prod ones can't.