Error: "changes to `lifecycle_commands` and/or `interpreter` should not be follwed by changes to other arguments"
Opened this issue · 2 comments
When I tried to run terraform plan
, I received this error:
changes to `lifecycle_commands` and/or `interpreter` should not be follwed by changes to other arguments
I'm not sure what it means. I'm using a shell
resource like so:
# modules/foo/main.tf
resource "shell_script" "this" {
lifecycle_commands {
create = file("${path.module}/create.sh")
delete = ""
read = ""
update = file("${path.module}/update.sh")
}
environment = {
NAME = "${var.name}"
}
}
# modules/foo/variables.tf
variable "name" {
type = string
}
# a_bunch_of_foos.tf
module "foo-1" {
source = "./modules/foo"
name = "bar"
}
module "foo-2" {
source = "./modules/foo"
name = "baz"
}
module "foo-2" {
source = "./modules/foo"
name = "quux"
}
Just ran into this too. The referenced code helped me understand what I should do differently.
Seems like if either lifecycle_commands
or interpreter
change, then any of environment
, sensitive_environment
, or working_directory
can't also change in the same plan. You have to break up your changes across two plans. I'm not quite sure why this is a requirement, but that's the workaround.
In my case, I had to change the script defining my lifecycle command first, and run its plan and apply. Then I changed my environment, and ran its plan and applied again.
This is such a frustrating bug. It can block an entire deploy if someone removes an input variable. It should absolutely be ok to change both at the same time.