Discussion below based on terraform-provider-azurerm v4.13.0
#27733 Introduces a couple of breaking changes:
-
Introduces
storage_account_id
inazurerm_storage_container
andazurerm_storage_share
and deprecates thestorage_account_name
. -
Depending on whether the new
storage_account_id
or the the deprecatedstorage_account_name
is used, the two resources above will change their behavior:storage_account_name
used: 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_id
is used, any downstream resource that depend on the id of theazurerm_storage_container
orazurerm_storage_share
will 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_container
andazurerm_storage_share
, since the import logic will import your resource with thestorage_account_id
only: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_id
attribute, 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 fromfileshares
toshares
: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_id
only, hence they are behaving as the new way, i.e. management resource id and management plane API only. -
Update the config for
azurerm_storage_container
andazurerm_storage_share
to usestorage_account_id
-
Update the config for the downstream resources that reference the id of
azurerm_storage_container
andazurerm_storage_share
:- For
azurerm_storage_share
downstream resources, changing fromazurerm_storage_share.foo.id
toazurerm_storage_share.foo.url
- For
azurerm_storage_container
downstream resources, there is no endpoint defined in this resource itself. While can be constructed by combiningazurerm_storage_account.foo.primary_blob_endpoint
andazurerm_storage_container.foo.name
- For