terraform-provider-shell icon indicating copy to clipboard operation
terraform-provider-shell copied to clipboard

Provider doesn't perform "update" when i'm changing the update script.

Open arielbeckjit opened this issue 2 years ago • 0 comments

Hi, so i have the following configuration:

resource "shell_script" "configure-data-api" {
  environment = {
    ENV = 1
  }
  sensitive_environment = {
    AUTH = var.creds
  }
  lifecycle_commands {
    create = file("${path.module}/configure_data_api_scripts/create.sh")
    update = file("${path.module}/configure_data_api_scripts/update.sh")
    read   = file("${path.module}/configure_data_api_scripts/get.sh")
    delete = file("${path.module}/configure_data_api_scripts/delete.sh")
  }
  interpreter = ["/bin/bash", "-c"]

  lifecycle {
    ignore_changes = [
      sensitive_environment
    ]
  }

  working_directory = path.module
}

The read is the one that outputs the state. I've enabled debug, and when i've done change in the update (echo something to file) - it just doesn't run. When i change afterward an env var, then it runs.

this is the log i'm seeing, it looks like update wasn't even run (no debug log from update)

2023-05-07T20:50:52.571+0300 [WARN]  Provider "registry.terraform.io/scottwinkler/shell" produced an invalid plan for module.......configure-data-api, but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .dirty: planned value cty.False for a non-computed attribute
      - .read_error: planned value cty.StringVal("") for a non-computed attribute
[0m[1mmodule........configure-data-api: Modifying... [id=ch922u7o42dch29efo30][0m[0m
2023-05-07T20:50:52.593+0300 [INFO]  Starting apply for module........shell_script.configure-data-api
2023-05-07T20:50:52.593+0300 [DEBUG] module......].shell_script.configure-data-api: applying the planned Update change
[0m[1mmodule.......t.configure-data-api: Modifications complete after 0s [id=ch922u7o42dch29efo30][0m

I've managed to see where's the problem, this code when update is performed:

	if d.HasChanges("lifecycle_commands", "interpreter") {
		return
	}

lifecycle_commands changes of course, because script is updated - so the update is not triggered...

related PR that added the bug https://github.com/scottwinkler/terraform-provider-shell/issues/81

arielbeckjit avatar May 07 '23 18:05 arielbeckjit