It is common to create modules that standardize infrastructure as code configurations. So, it is also common to have resources where the underlying code is not easily changed.
I have an issue where I have an existing Incus instance and a new volume. I would like to attach the volume to the existing Incus instance without editing the instance resource code. With the AWS provider I would do something like this:
I don’t think that there’s an easy way to do that as it would effectively require either modeling the devices separately as their own resources or having some kind of hybrid method where an attachment type resource would lead to the creation of devices without touching the instance resource but could lead to interesting edge cases (conflicts between the attachments and devices config).
You could make the instance module accept additional devices as an input. That would let you attach a volume from the calling configuration without editing the module each time:
The module would use a dynamic device block to add those to its Incus instance. It’s not quite a separate attachment resource as you would need to update the module once to support this, but it should cover the common use case.
So if you can’t change the module that manages the instance, there isn’t a Terraform-native way to do this today. You could attach it with incus storage volume attach, but Terraform wouldn’t manage that attachment, and a later apply could undo it.