I’ve got a github issue raised at: Unable to switch from `metadata_startup_script` to `metadata.startup-script` gracefully · Issue #9459 · hashicorp/terraform-provider-google · GitHub which I think is possibly the “fix”, but I’m also keen to be able to workaround it in the mean time.
The crux of the issue is that I want to swap from using
metadata.startup-script gracefully without destroying the VM (as it has data on it), as the use case for the script really exists around first time boot and it can get me stuck in instances where a simple refactor for the script would trigger a destroy/recreate.
I’ve been pointed towards using
terraform state mv which sounds promising but I’m having a bit of trouble either nailing the syntax, or understanding if what I’m trying to do is possible.
terraform state mv -dry-run 'module.elasticsearch-capture["oregon"].google_compute_instance.elasticsearch-data.metadata_startup_script' 'module.elasticsearch-capture["oregon"].google_compute_instance.elasticsearch-data.metadata["startup-script"]'
╷ │ Error: Invalid address │ │ on line 1: │ (source code not available) │ │ Resource instance key must be given in square brackets. ╵╷ │ Error: Invalid address │ │ on line 1: │ (source code not available) │ │ Unexpected extra operators after address. ╵