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

Case sensitivity causing exports to fail #473

Open
skadz opened this issue Nov 10, 2023 · 1 comment
Open

Case sensitivity causing exports to fail #473

skadz opened this issue Nov 10, 2023 · 1 comment
Labels
question Further information is requested

Comments

@skadz
Copy link

skadz commented Nov 10, 2023

I'm trying to export a resource group and it was chugging along great until it hit this error:

Error: Failed to import /subscriptions/aaaaaaaa-0000-aaaa-aa-aaaaaaaaaaaa/resourceGroups/defaultresourcegroup-eus/providers/Microsoft.OperationsManagement/solutions/SQLAuditing[defaultworkspace-defaultworkspace-aaaaaaaa-0000-aaaa-aa-aaaaaaaaaaaa-eus] as azurerm_log_analytics_solution.res-575: exit status 1

Error: expected "SQLAuditing[defaultworkspace-aaaaaaaa-0000-aaaa-aa-aaaaaaaaaaaa-eus]" to match 'Solution(WorkspaceName)'

When I investigated the issue, I saw that the rest of the resources use this as the resource group name:

DefaultWorkspace-aaaaaaaa-0000-aaaa-aa-aaaaaaaaaaaa-EUS

but this one uses:

defaultworkspace-aaaaaaaa-0000-aaaa-aa-aaaaaaaaaaaa-eus

Any chance this match could be made case insensitive?

@magodo
Copy link
Collaborator

magodo commented Nov 13, 2023

@skadz From the error message:

Error: expected "SQLAuditing[defaultworkspace-aaaaaaaa-0000-aaaa-aa-aaaaaaaaaaaa-eus]" to match 'Solution(WorkspaceName)'

It seems the resource name violates the expectation of the provider, which is defined at https://github.com/hashicorp/terraform-provider-azurerm/blob/fc0bfa18efa74a94c24b12eda48b00cb508c7d22/internal/services/loganalytics/log_analytics_solution_resource.go#L223-L236:

				// Reversing the mapping used to get .solution_name
				// expecting resp.Name to be in format "SolutionName(WorkspaceName)".
				if v := model.Name; v != nil {
					val := pointer.From(v)
					segments := strings.Split(val, "(")
					if len(segments) != 2 {
						return fmt.Errorf("expected %q to match 'Solution(WorkspaceName)'", val)
					}

					solutionName := segments[0]
					workspaceName := strings.TrimSuffix(segments[1], ")")
					state.SolutionName = solutionName
					state.WorkspaceName = workspaceName
				}

This means if you manually run terraform import to import this resource, you'll get the same error. This either indicates the provider doesn't support importing this resource, or you shall not import this resource at all (as it is a built-in resource managed by other means)?

@magodo magodo added the question Further information is requested label Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants