-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
azurerm_storage_share
- Fix a bug that using storage_account_id
accidentally leaks to the wrong branch for creation
#28063
Conversation
…ccidentally leaks to the wrong branch for creation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @magodo - Thanks for this PR. Unfortunately it breaks the intended purpose of having introduced the storage_account_id
property, which is to discontinue use of the Data Plane API entirely when it is specified, as this is required for users that have no Terraform access to Data Plane endpoints for various reasons. Can you restore those code paths and take another look at resolving the referenced bug leaving that functionality intact?
Thanks
@@ -160,6 +160,7 @@ func resourceStorageShare() *pluginsdk.Resource { | |||
r.Schema["storage_account_name"] = &pluginsdk.Schema{ | |||
Type: pluginsdk.TypeString, | |||
Optional: true, | |||
Computed: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not be setting this value if storage_account_id
is set
Computed: true, |
@@ -171,6 +172,7 @@ func resourceStorageShare() *pluginsdk.Resource { | |||
r.Schema["storage_account_id"] = &pluginsdk.Schema{ | |||
Type: pluginsdk.TypeString, | |||
Optional: true, | |||
Computed: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not be setting this value if storage_account_id
is set.
Computed: true, |
if accountName := d.Get("storage_account_name").(string); accountName != "" { | ||
shareName := d.Get("name").(string) | ||
quota := d.Get("quota").(int) | ||
metaDataRaw := d.Get("metadata").(map[string]interface{}) | ||
metaData := ExpandMetaData(metaDataRaw) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing this means that we will use the Data Plane client even in the cases that storage_account_id
is specified in place of storage_account_name
, which we specifically need to avoid for this change to separate the the two APIs. If storage_account_id
is specified, we must use exclusively the Resource Manager API.
if !features.FivePointOhBeta() && !strings.HasPrefix(d.Id(), "/subscriptions/") { | ||
if !features.FivePointOhBeta() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, this must be evaluated to ensure that cases where the ID is the resource manager ID, we exclusively use the Resource Manager API.
e4b9826
to
4db7855
Compare
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
Community Note
Description
With the introduction of
storage_account_id
on theazurerm_storage_share
in #27733, there is one bug in the creation code, that if users specify the newstorage_account_id
property (withstorage_account_name
omitted, as they are in conflict), the logic leaks to the v5 part, which is causing issues like #28032.This PR fixes that part by:
storage_account_name
check, but infer the account name from the id ifstorage_account_id
is usedstorage_account_[id|name]
as Computed, per the breaking change guideline&& !strings.HasPrefix(d.Id(), "/subscriptions/")
Additionally, I've reverted the changes on the acctest config, for the acl timestamp format, for the compatibility purpose. Note that the format is different between data plane and mgmt plane APIs. Meanwhile, I've modified the
flattenStorageShareACLs
to convert the timestamp format back to the data plane version.PR Checklist
For example: “
resource_name_here
- description of change e.g. adding propertynew_property_name_here
”Changes to existing Resource / Data Source
Testing
Without v5 toggle
With v5 toggle
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_storage_share
- Fix a bug that usingstorage_account_id
accidentally leaks to the wrong branch for creation [GH-00000]This is a (please select all that apply):
Related Issue(s)
Fixes #28032
Note
If this PR changes meaningfully during the course of review please update the title and description as required.