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_automation_powershell72_module can't import newer versions of default modules #28273

Closed
1 task done
massimolpc opened this issue Dec 13, 2024 · 2 comments · Fixed by #28291
Closed
1 task done

Comments

@massimolpc
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 comments along the lines of "+1", "me too" or "any updates", 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 and review the contribution guide to help.

Terraform Version

1.4.6

AzureRM Provider Version

4.11

Affected Resource(s)/Data Source(s)

azurerm_automation_powershell72_module

Terraform Configuration Files

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_automation_account" "example" {
  name                = "account1"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  sku_name            = "Basic"
}

resource "azurerm_automation_powershell72_module" "az_accounts" {
  name                    = "Az.Accounts"
  automation_account_id   = azurerm_automation_account.example.id

  module_link {
    uri = "https://www.powershellgallery.com/api/v2/package/Az.Accounts/4.0.0"
  }
}

Debug Output/Panic Output

Error: A resource with the ID "/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/example-resources/providers/Microsoft.Automation/automationAccounts/account1/powerShell72Modules/Az.Accounts" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_automation_powershell72_module" for more information.

Expected Behaviour

The module should be able to be imported with the desired version

Actual Behaviour

The module can't be imported, and there's no way to force it to import with a newer version. I suppose you could try to import the existing module and then set it to use a newer version, but that's not a very elegant solution.

Steps to Reproduce

terraform apply

Important Factoids

No response

References

the same problem was described for the azurerm_automation_module resource
#18198
and fixed with
#18434

@rcskosir
Copy link
Contributor

rcskosir commented Jan 7, 2025

Thank you for taking the time to open this issue. Please subscribe to PR #28291 created for this issue.

@Noel-Jones
Copy link
Contributor

Noel-Jones commented Jan 14, 2025

The title is not entirely clear on the issue. I see the same error as described but it is possible to import the existing (global) module, e.g.

terraform import 'azurerm_automation_powershell72_module.az_accounts' "/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.Automation/automationAccounts/aa-xxx/powerShell72Modules/Az.Accounts"

After this the example shown would load v4.0.0 and it would show as a custom resource in the UI. Terraform is able to delete the resource, which removes the custom module. (Then you are back to needing to import again should you decide to try again.)

The PR looks appropriate to resolve the issue but I haven't tested it.

@github-actions github-actions bot added this to the v4.17.0 milestone Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants