I use terraform to configure the storage account, containers, shares.
A question arised - can I upload a file to an Azure storage account file share with terraform? I cannot find the respective resource.
EDIT 1
An idea that comes is to use the null_resource
. I wonder how it fits with the benefits of using terraform, which are in my opinion:
Other potential benefits could be enforcing the desired state, though, this is more potentially and in the future, rather than current. Indeed, try deleting a resource outside of terraform. In theory and in the future it could recognise it and recreate, today it just fails. But the potential is there.
All these benefits are enough to justify using it, even though I sometimes want to bang my head on the wall trying to do something with it.
Now, how all these benefits fit into running a custom script within a null_resource
? Surely inspecting the plan would not help with a general purpose script inside a resource. I wonder how it fares against the other benefits?
For anyone coming from Google, it's worth pointing out you should now be able to use azurerm_storage_share_file. This worked great for me to upload a single file. To upload multiple files it looks like you will require multiple resources
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_share_file
resource "azurerm_storage_share_file" "example" {
name = "test.txt"
storage_share_id = azurerm_storage_share.example.id
source = "${path.root}/TestFile/test.txt"
}