-
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
Update segment of resource id for network packet capture #8167
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.
We should check both the old and the new path in case users still have the old path.
@mbfrahry, it's not appropriate for this case. Because the segment of resource id of the 2018-08-01 version terraform initially used is also updated to "packetCaptures". So I think this issue would also happen on older version. After tested with old version, this issue also happened. So I assume we don't need to be aware of compatible problem for this case. Based on above conclusion, I assume all users are blocked on all released azurerm provider versions now. |
@tombuildsstuff ,@mbfrahry, although it's a breaking change, but I assume all users are blocked now by this issue on all released azurerm provider versions. Could we merge it to unblock users first? |
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.
Taking a look though here unfortunately this would be a breaking change for existing users - as such we'll need to add a state migration to update these ID's to the new format here.
Thanks!
@@ -217,7 +217,7 @@ func resourceArmNetworkPacketCaptureRead(d *schema.ResourceData, meta interface{ | |||
|
|||
resourceGroup := id.ResourceGroup | |||
watcherName := id.Path["networkWatchers"] | |||
name := id.Path["NetworkPacketCaptures"] | |||
name := id.Path["packetCaptures"] |
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.
unfortunately where this will be different for older resources we'd need to add a state migration to update this ID - as-is this is a breaking change
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.
Updated code
@@ -266,7 +266,7 @@ func resourceArmNetworkPacketCaptureDelete(d *schema.ResourceData, meta interfac | |||
|
|||
resourceGroup := id.ResourceGroup | |||
watcherName := id.Path["networkWatchers"] | |||
name := id.Path["NetworkPacketCaptures"] | |||
name := id.Path["packetCaptures"] |
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.
unfortunately where this will be different for older resources we'd need to add a state migration to update this ID - as-is this is a breaking change
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.
Updated code
@tombuildsstuff , thanks for the comment. I've updated code to use MigrateState. After used MigrateState, I assume this PR doesn't belong to "breaking-change", right? |
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.
if we can confirm the state migration works then this otherwise LGTM 👍
|
||
log.Printf("[DEBUG] ARM Network Packet Capture before Migration: %#v", is.Attributes) | ||
|
||
newID := strings.Replace(is.Attributes["id"], "/NetworkPacketCaptures/", "/packetCaptures/", 1) |
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 you confirm this migration works correctly when provisioning a resource using 2.0.0 -> that then shows no diff using tis branch?
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.
@tombuildsstuff , yes. I tested the scenario you mentioned and it works fine.
The scenario:
- Create Network Packet Captures with 2.0.0 (Also tried 1.27.0)
- Run
tf plan
with this branch - There is no diff.
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 @neil-yechenwei - Can you post the manual test results / output here? (Ideally with an apply
rather than a plan
as this will actually update the state and exercise the code.).
Thanks
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.
@jackofallops , sure.
- Run
tf apply
to create Network Packet Capture with provider.azurerm v2.0.0 (I have to manually update the name segment to "NetworkPacketCaptures" since the name segment in all api versions has been updated to "packetCaptures" such as api version 2018-08-01. So we cannot get old value anymore.)
azurerm_network_packet_capture.test: Creation complete after 16s [id=/subscriptions/xx-xx-xx-xx/resourceGroups/acctestRG-watcher-test01/providers/Microsoft.Network/networkWatchers/acctestnw-test01/NetworkPacketCaptures/acctestpc-test02]
2. Switch provider.azurerm from v2.0.0 to this branch
3. Run tf plan
azurerm_network_packet_capture.test: Refreshing state... [id=/subscriptions/xx-xx-xx-xx/resourceGroups/acctestRG-watcher-test01/providers/Microsoft.Network/networkWatchers/acctestnw-test01/packetCaptures/acctestpc-test02]
azurerm_network_packet_capture.test: Refreshing state... [id=/subscriptions/xx-x-xx-xx/resourceGroups/acctestRG-watcher-test01/providers/Microsoft.Network/networkWatchers/acctestnw-test01/packetCaptures/acctestpc-test02]
5. Update the name of network packet capture in tfconfig. (I cannot test update scenario since this resource doesn't support update operation.)
6. Run tf apply
azurerm_network_packet_capture.test: Creation complete after 5s [id=/subscriptions/xx-xx-xx-xxx/resourceGroups/acctestRG-watcher-test01/providers/Microsoft.Network/networkWatchers/acctestnw-test01/packetCaptures/acctestpc-test03]
azurerm_network_packet_capture.test: Refreshing state... [id=/subscriptions/xx-xx-xx-xx/resourceGroups/acctestRG-watcher-test01/providers/Microsoft.Network/networkWatchers/acctestnw-test01/packetCaptures/acctestpc-test03]
azurerm_network_packet_capture.test: Destroying... [id=/subscriptions/xx-x-x-xx/resourceGroups/acctestRG-watcher-test01/providers/Microsoft.Network/networkWatchers/acctestnw-test01/packetCaptures/acctestpc-test03]
azurerm_network_packet_capture.test: Destruction complete after 2s
@jackofallops , thanks for your comments. I've posted manual test results. Please have a look. Thanks. |
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.
Thanks @neil-yechenwei, this LGTM now 👍
outdated
This has been released in version 2.28.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example: provider "azurerm" {
version = "~> 2.28.0"
}
# ... other configuration ... |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
As this resource cannot be deleted anymore for incorrect resource id segment issue, so we have to update segment of resource id here for this resource.
--- PASS: TestAccAzureRMNetworkWatcher/PacketCapture (1924.64s)
--- PASS: TestAccAzureRMNetworkWatcher/PacketCapture/localDisk (453.99s)
--- PASS: TestAccAzureRMNetworkWatcher/PacketCapture/storageAccount (504.75s)
--- PASS: TestAccAzureRMNetworkWatcher/PacketCapture/storageAccountAndLocalDisk (446.00s)
--- PASS: TestAccAzureRMNetworkWatcher/PacketCapture/withFilters (519.90s)
--- PASS: TestAccAzureRMNetworkWatcher/PacketCapture/requiresImport (532.44s)