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

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

Closed
1 task done
darren-johnson opened this issue Sep 13, 2022 · 4 comments · Fixed by #18467

Comments

@darren-johnson
Copy link

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.9

AzureRM Provider Version

3.22.0

Affected Resource(s)/Data Source(s)

azurerm_security_center_workspace

Terraform Configuration Files

resource "azurerm_security_center_workspace" "workspace" {
  scope        = join("", ["/subscriptions/", data.azurerm_subscriptions.msdn.subscriptions.0.subscription_id])
  workspace_id = azurerm_log_analytics_workspace.workspace.id
}

Debug Output/Panic Output

Error: parsing segment "staticResourceGroups": expected the segment "resourcegroups" to be "resourceGroups"

Expected Behaviour

Should work.

Appears the same issue as #18235 .

Actual Behaviour

Brand new configuration which fails to deploy or destroy. Other security center resources are present in state and need removing via the CLI to destroy.

Error: Reading Security Center Log Analytics Workspace ID: parsing "/subscriptions/SUB_ID/resourcegroups/RG_NAME/providers/microsoft.operationalinsights/workspaces/WORKSPACE_NAME": parsing segment "staticResourceGroups": expected the segment "resourcegroups" to be "resourceGroups"

Present in state file as per below:

tf state show azurerm_security_center_workspace.workspace
# azurerm_security_center_workspace.workspace: (tainted)
resource "azurerm_security_center_workspace" "workspace" {
    id           = "/subscriptions/SUB_ID/providers/Microsoft.Security/workspaceSettings/default"
    scope        = "/subscriptions/SUB_ID"
    workspace_id = "/subscriptions/SUB_ID/resourceGroups/RG_NAME/providers/Microsoft.OperationalInsights/workspaces/WORKSPACE_NAME"
}

Steps to Reproduce

No response

Important Factoids

No response

References

No response

@myc2h6o
Copy link
Contributor

myc2h6o commented Sep 15, 2022

Hi @darren-johnson thanks for opening the issue! The issue seems to be similar to #17426, I'll be checking if we could apply the same fix for this.

@grillba
Copy link

grillba commented Sep 19, 2022

Hi @myc2h6o,

This is identical to #18244 which was incorrectly closed as a duplicate. I've added some information to the bottom of that ticket here #18244 (comment)

The issue is a result of a lower cased resource ID being stored in Azure from a previous version of the provider. After upgrade to 3.21.0 or above, the provider is incorrectly doing a case sensitive parse of the returned value from the Azure API.

Happy to send on some diagnostics information if you'd like

@josh-barker
Copy link
Contributor

josh-barker commented Sep 21, 2022

Hey @myc2h6o and @tombuildsstuff ,

As per 18244, the response string from Azure is not the correct case.

I've also looked at older LAW's and their id is /subscriptions/xxx/resourcegroups/xxx, whereas a newly deployed LAW has /subscriptions/xxx/resourceGroups/xxx. Potentially the id format has changed over time?

There could be an issue in the Read function as it's using workspaces.ParseWorkspaceID, instead of ParseWorkspaceIDInsensitively.

I can put together a PR if that's helpful?

favoretti added a commit to favoretti/terraform-provider-azurerm that referenced this issue Sep 21, 2022
`azurerm_monitor_diagnostic_settings`: fix casing parsing
`azurerm_user_assigned_identity`: fix casing parsing
`azurerm_security_center_workspace`: fix casing parsing

Fixes hashicorp#18346
Fixes hashicorp#14853
Fixes hashicorp#18360
@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 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants