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_log_analytics_workspace WorkspaceMigrateState looking up resource_group rather than resource_group_name #9790

Closed
Mobe1969 opened this issue Dec 9, 2020 · 3 comments · Fixed by #9853

Comments

@Mobe1969
Copy link

Mobe1969 commented Dec 9, 2020

I'm running the latest version and am trying to redeploy a log analytics workspace, and for some reason it is triggering this WorkspaceMigrateState call, and this code is trying to lookup an attribute (resource_group) that isn't part of the azurerm_log_analytics_workspace definition, and as far as I can tell going back through releases back to 1.24 was not part of it then. I believe it should be looking up resource_group_name.

Anyhow, it is then triggering an error as it gets a null resource group for use.

I can't see why this code is actually being called either.


func WorkspaceMigrateState(v int, is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) {
	switch v {
	case 0:
		log.Println("[INFO] Migrating Log Analytics Workspace State V0 to V1")
		return workspaceStateMigrateV0toV1(is, meta)
	default:
		return is, fmt.Errorf("Unexpected schema version: %d", v)
	}
}

func workspaceStateMigrateV0toV1(is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) {
	if is.Empty() {
		log.Println("[DEBUG] Empty InstanceState; nothing to migrate.")
		return is, nil
	}

	log.Printf("[DEBUG] Migrating IDs to correct casing for Log Analytics Workspace")
	name := is.Attributes["name"]
	resourceGroup := is.Attributes["resource_group"]
	subscriptionId := meta.(*clients.Client).Account.SubscriptionId
	id := parse.NewLogAnalyticsWorkspaceID(name, resourceGroup)
	is.ID = id.ID(subscriptionId)

	return is, nil
}
@Mobe1969
Copy link
Author

Just a note - I've gone back thru versions, and this only starts happening from version 2.36.0 and onwards. 2.35.0 was fine.

@ghost
Copy link

ghost commented Dec 17, 2020

This has been released in version 2.41.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.41.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Jan 15, 2021

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!

@ghost ghost locked as resolved and limited conversation to collaborators Jan 15, 2021
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.

2 participants