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

Wait for cloud init to complete in `incus_instance` resource (report error if there is any)

Open breml opened this issue 4 months ago • 4 comments

As mentioned in #86, currently the terraform provider does not detect errors in cloud init and additionally, the terraform provider is not able to detect, when cloud init is done.

Cloud init offers an option to wait for cloud-init to complete with cloud-init status --wait (additionally, --format json can be provided for an easy to process result). Therefore I think it could be possible to extend the provider such, that after successful creation of the instance, the provider could exec the before mentioned command in order to wait for cloud init to complete (and return the error if there is one).

Therefore I propose to add another type of wait_for, which allows to wait for the cloud init to complete.

breml avatar Jul 22 '25 20:07 breml

Yeah, we usually try to avoid using ExecInstance inside of the terraform provider but for this one that seems reasonable and it would fit nicely into the wait_for framework.

stgraber avatar Jul 22 '25 21:07 stgraber

This would be a really nice way to completely avoid needing an "exec" capability (#27, #86) in many cases.

The common response to wanting to exec in Terraform in general is "use provisioning / configuration management tools", but even if you bootstrap what's needed for those in cloud-init (SSH keys for Ansible, agent for Puppet, etc) you still need to run a remote command to wait for cloud-init to be done before you can reliably kick off your configuration management tool.

Being able to wait_for would remove the need for executing a remote command to do that, and in most cases would mean any requirement to run a remote command could be moved out of Terraform and into suitable tooling such as Ansible.

zofrex avatar Nov 15 '25 17:11 zofrex

@breml so we would have another wait_for type which would be in this case cloud_init?

maveonair avatar Nov 16 '25 11:11 maveonair

@maveonair Yes, correct. I think cloud_init would be a reasonable name for the proposed new value for wait_for.

breml avatar Nov 18 '25 05:11 breml