Discussion below based on terraform-provider-azurerm v4.13.0
#27733 Introduces a couple of breaking changes:
-
Introduces
storage_account_idinazurerm_storage_containerandazurerm_storage_shareand deprecates thestorage_account_name. -
Depending on whether the new
storage_account_idor the the deprecatedstorage_account_nameis used, the two resources above will change their behavior:storage_account_nameused: Data plane API is used to manage the resource. The resource id is the data plane endpointstorage_account_id: used: Management plane API is used to manage the resource. The resource id is the management plane id
-
If the
storage_account_idis used, any downstream resource that depend on the id of theazurerm_storage_containerorazurerm_storage_sharewill break (as it is now a management palne id).Examples:
azurerm_storage_share_file,azurerm_storage_share_directory
Following sections talks about how to manually migrate to using the new storage_account_id for modules not applied (i.e. stateless), and modules that have been applied (i.e. stateful).
-
(stateful only) Re-import the
azurerm_storage_containerandazurerm_storage_share, since the import logic will import your resource with thestorage_account_idonly:For
azurerm_storage_container:addr=azurerm_storage_container.foo id=$(terraform state show $addr | hclgrep -x 'resource_manager_id = $x' -w x | tr -d '"') terraform state rm $addr terraform import $addr $id
For
azurerm_storage_share, though it also has theresource_manager_idattribute, but it is a slightly different in the old version (the one in the state) than the expected one. The last segment has to be renamed fromfilesharestoshares:addr=azurerm_storage_share.foo id=$(terraform state show $addr | hclgrep -x 'resource_manager_id = $x' -w x | tr -d '"'| sed 's;/fileshares/;/shares/;') terraform state rm $addr terraform import $addr $id
The two resources are now imported with
storage_account_idonly, hence they are behaving as the new way, i.e. management resource id and management plane API only. -
Update the config for
azurerm_storage_containerandazurerm_storage_shareto usestorage_account_id -
Update the config for the downstream resources that reference the id of
azurerm_storage_containerandazurerm_storage_share:- For
azurerm_storage_sharedownstream resources, changing fromazurerm_storage_share.foo.idtoazurerm_storage_share.foo.url - For
azurerm_storage_containerdownstream resources, there is no endpoint defined in this resource itself. While can be constructed by combiningazurerm_storage_account.foo.primary_blob_endpointandazurerm_storage_container.foo.name
- For
hclgrep: https://github.com/magodo/hclgrep