Skip to content
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

parsing segment "staticResourceGroups": expected the segment "resourcegroups" to be "resourceGroups" #18244

Closed
1 task done
grillba opened this issue Sep 5, 2022 · 7 comments

Comments

@grillba
Copy link

grillba commented Sep 5, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

1.2.8

AzureRM Provider Version

3.21.1

Affected Resource(s)/Data Source(s)

azurerm_security_center_workspace

Terraform Configuration Files

data "azurerm_subscription" "current" {}

resource "azurerm_security_center_workspace" "this" {
  scope        = data.azurerm_subscription.current.id
  workspace_id = "/subscriptions/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/resourcegroups/rg-01/providers/microsoft.operationalinsights/workspaces/law-management-01"
}

Debug Output/Panic Output

│ Error: Reading Security Center Log Analytics Workspace ID: parsing "/subscriptions/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/resourcegroups/rg-01/providers/microsoft.operationalinsights/workspaces/law-management-01": parsing segment "staticResourceGroups": expected the segment "resourcegroups" to be "resourceGroups"
│ 
│   with module.shared.azurerm_security_center_workspace.this,
│   on ../modules/subscription/main.tf line 46, in resource "azurerm_security_center_workspace" "this":
│   46: resource "azurerm_security_center_workspace" "this" {

Expected Behaviour

Resource deploys successfully similar to 3.18.0

Actual Behaviour

│ Error: Reading Security Center Log Analytics Workspace ID: parsing "/subscriptions/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/resourcegroups/rg-01/providers/microsoft.operationalinsights/workspaces/law-management-01": parsing segment "staticResourceGroups": expected the segment "resourcegroups" to be "resourceGroups"

│ with module.shared.azurerm_security_center_workspace.this,
│ on ../modules/subscription/main.tf line 46, in resource "azurerm_security_center_workspace" "this":
│ 46: resource "azurerm_security_center_workspace" "this" {

Steps to Reproduce

Upgraded from 3.18.0 to 3.21.1 and the deployment of azurerm_security_center_workspace is now requiring title case for "resourceGroups" in the workspace_id.

Our configuration has the resource ID in lower case.

Important Factoids

No response

References

No response

@liuwuliuyun

This comment was marked as off-topic.

@liuwuliuyun

This comment was marked as off-topic.

@tombuildsstuff
Copy link
Contributor

@liuwuliuyun this isn't a bug - previously the validation didn't validate this casing when it should have been - this needs to be resolved by correcting the user input / adding a state migration as required.

@tombuildsstuff
Copy link
Contributor

tombuildsstuff commented Sep 5, 2022

Duplicate of #18235 - looks like we need a state migration here to account for the wrong Resource ID casing being imported previously

@J0F3
Copy link

J0F3 commented Sep 5, 2022

Same for azurerm_monitor_diagnostic_setting starting with azurerm version 3.21.

@tombuildsstuff Why is this not a bug? Everything works with azurerm version 3.20. Now with 3.21 existing, previous, working deployments are brocken/blocked because of this error. So this is definitely a bug in azurerm which should to be fixed immediately.

Azure Resource IDs are and were never case sensitive. So why does care the azurerm provider now after a minor update (which should not included breaking changes) suddenly about the casing of Azure Resource IDs!?

@grillba
Copy link
Author

grillba commented Sep 19, 2022

@tombuildsstuff any chance this can be reopened as it appears unrelated to #18235 and the fixes in 3.22.0 did not correct the issue.

I've done some further debugging and the lower cased "resourcegroup" in the ID is stored in Azure and is being returned by an API call during the plan stage.

2022-09-19T05:19:42.7186185Z 2022-09-19T15:19:18.875+1000 [DEBUG] provider.terraform-provider-azurerm_v3.23.0_x5: AzureRM Response for https://management.azure.com/subscriptions/eba843e0-aaf6-47a4-a30f-bcb1f90e4c08/providers/Microsoft.Security/workspaceSettings/default?api-version=2017-08-01-preview: 
2022-09-19T05:19:42.7186928Z HTTP/2.0 200 OK
2022-09-19T05:19:42.7187339Z Api-Supported-Versions: 1.0
2022-09-19T05:19:42.7187746Z Cache-Control: no-cache
2022-09-19T05:19:42.7188292Z Content-Type: application/json; charset=utf-8
2022-09-19T05:19:42.7188802Z Date: Mon, 19 Sep 2022 05:19:18 GMT
2022-09-19T05:19:42.7189227Z Expires: -1
2022-09-19T05:19:42.7189598Z Pragma: no-cache
2022-09-19T05:19:42.7189859Z Server: Kestrel
2022-09-19T05:19:42.7190350Z Strict-Transport-Security: max-age=31536000; includeSubDomains
2022-09-19T05:19:42.7190826Z Vary: Accept-Encoding
2022-09-19T05:19:42.7191251Z X-Content-Type-Options: nosniff
2022-09-19T05:19:42.7191805Z X-Ms-Correlation-Request-Id: 9b382cbd-28ed-fca1-715c-c158b3cf5cb2
2022-09-19T05:19:42.7192390Z X-Ms-Ratelimit-Remaining-Subscription-Resource-Requests: 749
2022-09-19T05:19:42.7192963Z X-Ms-Request-Id: 8177da67-12d0-4b36-a6b4-60fbf0c8a5bf
2022-09-19T05:19:42.7193674Z X-Ms-Routing-Request-Id: AUSTRALIASOUTHEAST:20220919T051918Z:84d99cb0-a851-4e5f-8112-4543ac57a392
2022-09-19T05:19:42.7193971Z 
2022-09-19T05:19:42.7195578Z {"id":"/subscriptions/eba843e0-aaf6-47a4-a30f-bcb1f90e4c08/providers/Microsoft.Security/workspaceSettings/default","name":"default","type":"Microsoft.Security/workspaceSettings","properties":{"workspaceId":"/subscriptions/25bb711d-fde4-46b2-a618-3ca494ebe01b/resourcegroups/prg-aus-prci-management-01/providers/microsoft.operationalinsights/workspaces/law-aus-brdev-prci-management-01","scope":"/subscriptions/eba843e0-aaf6-47a4-a30f-bcb1f90e4c08"}}: timestamp=2022-09-19T15:19:18.838+1000
2022-09-19T05:19:42.7197899Z 2022-09-19T15:19:18.880+1000 [TRACE] provider.terraform-provider-azurerm_v3.23.0_x5: Called downstream: @module=sdk.helper_schema tf_provider_addr=provider tf_resource_type=azurerm_security_center_workspace tf_rpc=ReadResource @caller=github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:1016 tf_req_id=d9259427-4e17-5c63-8a74-c2099b11f421 timestamp=2022-09-19T15:19:18.838+1000
2022-09-19T05:19:42.7200517Z 2022-09-19T15:19:18.880+1000 [TRACE] provider.terraform-provider-azurerm_v3.23.0_x5: Received downstream response: diagnostic_error_count=1 diagnostic_warning_count=0 tf_req_id=d9259427-4e17-5c63-8a74-c2099b11f421 tf_resource_type=azurerm_security_center_workspace tf_rpc=ReadResource @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/tf5serverlogging/downstream_request.go:38 @module=sdk.proto tf_provider_addr=provider tf_req_duration_ms=903 tf_proto_version=5.2 timestamp=2022-09-19T15:19:18.838+1000
2022-09-19T05:19:42.7204160Z 2022-09-19T15:19:18.880+1000 [ERROR] provider.terraform-provider-azurerm_v3.23.0_x5: Response contains error diagnostic: diagnostic_severity=ERROR diagnostic_summary="Reading Security Center Log Analytics Workspace ID: parsing "/subscriptions/25bb711d-fde4-46b2-a618-3ca494ebe01b/resourcegroups/prg-aus-prci-management-01/providers/microsoft.operationalinsights/workspaces/law-aus-brdev-prci-management-01": parsing segment "staticResourceGroups": expected the segment "resourcegroups" to be "resourceGroups"" tf_proto_version=5.2 tf_provider_addr=provider tf_req_id=d9259427-4e17-5c63-8a74-c2099b11f421 @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:56 @module=sdk.proto diagnostic_detail= tf_resource_type=azurerm_security_center_workspace tf_rpc=ReadResource timestamp=2022-09-19T15:19:18.838+1000
2022-09-19T05:19:42.7207305Z 2022-09-19T15:19:18.880+1000 [TRACE] provider.terraform-provider-azurerm_v3.23.0_x5: Served request: tf_proto_version=5.2 tf_rpc=ReadResource @module=sdk.proto tf_provider_addr=provider tf_req_id=d9259427-4e17-5c63-8a74-c2099b11f421 tf_resource_type=azurerm_security_center_workspace @caller=github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:759 timestamp=2022-09-19T15:19:18.838+1000
2022-09-19T05:19:42.7209130Z 2022-09-19T15:19:18.880+1000 [DEBUG] provider.terraform-provider-azurerm_v3.23.0_x5: AzureRM Response for https://management.azure.com/subscriptions/293914b3-1a2e-4484-998d-c20169a486a7/providers/Microsoft.Security/workspaceSettings/default?api-version=2017-08-01-preview: 

There appears to be no work around other that destroying the resource outside of Terraform or deleting the current resource from state.

Also changing the case of the Workspace resource ID had no impact on the value stored in Azure using a provider version prior to 3.21.0

Happy to send on the full diagnostics trace if needed.

@github-actions
Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants