-
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_api_management_api_policy
, azurerm_api_management_api_operation_policy
, azurerm_api_management_product_policy
: fix parsing resource id error
#23128
Conversation
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.
hey @sinbai
Thanks for this PR - taking a look through on the whole this looks pretty good but since we're updating these IDs we should also look to parse/reformat the ID too to ensure that the resourceGroups
and other segments are correct at the same time. However if we can fix that up then this should otherwise be good to go 👍
Thanks!
newId := strings.TrimSuffix(oldId, "/policies/policy") | ||
|
||
log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId) | ||
rawState["id"] = newId |
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.
can we parse the updated ID and reformat it such that we can ensure the resourceGroups
and other segments are correct too? e.g.:
newId := strings.TrimSuffix(oldId, "/policies/policy") | |
log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId) | |
rawState["id"] = newId | |
newId := strings.TrimSuffix(oldId, "/policies/policy") | |
parsed, err := policy.ParseServiceID(newID) | |
if err != nil { | |
return err | |
} | |
newId = parsed.ID() | |
log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId) | |
rawState["id"] = newId |
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.
Fixed.
newId := strings.TrimSuffix(oldId, "/policies/policy") | ||
|
||
log.Printf("[DEBUG] Updating ID from %q tmakeo %q", oldId, newId) | ||
rawState["id"] = newId |
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.
(same here / as above)
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.
Fixed.
newId := strings.TrimSuffix(oldId, "/policies/policy") | ||
|
||
log.Printf("[DEBUG] Updating ID from %q tmakeo %q", oldId, newId) | ||
rawState["id"] = newId |
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.
(same here)
newId := strings.TrimSuffix(oldId, "/policies/policy") | |
log.Printf("[DEBUG] Updating ID from %q tmakeo %q", oldId, newId) | |
rawState["id"] = newId | |
newId := strings.TrimSuffix(oldId, "/policies/policy") | |
log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId) | |
rawState["id"] = newId |
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.
Fixed.
Hi @tombuildsstuff , thanks for your feedback. The code has been updated. Could you please take another look? |
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.
LGTM 🪐
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. |
For resources
azurerm_api_management_api_policy
,azurerm_api_management_api_operation_policy
,azurerm_api_management_product_policy
, after importing the resource using a version before v3.70.0 of Terraform Provider, the id in state file ends with "/policies/policy", and the id in state file ends with "/policies/xml" when creating resource by Terraform. Therefore, when migrating Pandora SDK, both cases need to be migrated.In PR #22783 only the case where the ID ends with "/policies/xml" is processed, so submit this PR to process the case where the ID ends with "/policies/policy" to solve the parsing id error.
Might fix issue #23112, #23095.
Local manual testing, the steps are as follows: