Search code examples
terraformterraform-provider-azure

How I can to import my automation account job schedule in Terraform?


How can I import my schedule job of my runbook of my automation account to manage it from Terraform?

We have created it from outside our IaC and now we need it to be managed from Terraform so that everything is integrated correctly.

I have been running the following. But none of these commands work:

terraform import 'module.automation_account_powershell["eastus"].azurerm_automation_job_schedule.atm' /subscriptions/xxx/resourceGroups/rg-phoenix2cloud-pro-eastus/providers/Microsoft.Automation/automationAccounts/aa-eastus-pro/jobSchedules/filesharepvc

terraform import 'module.automation_account_powershell["eastus"].azurerm_automation_job_schedule.atm' /subscriptions/xxx/resourceGroups/rg-phoenix2cloud-pro-eastus/providers/Microsoft.Automation/automationAccounts/aa-eastus-pro/schedules/filesharepvc

terraform import 'module.automation_account_powershell["eastus"].azurerm_automation_job_schedule.atm' /subscriptions/xxx/resourceGroups/rg-pro-eastus/providers/Microsoft.Automation/automationAccounts/aa-eastus-pro/jobSchedules/subscriptions/xxx/resourceGroups/rg-pro-eastus/providers/Microsoft.Automation/automationAccounts/aa-eastus-pro/schedules/filesharepvc

Is it possible to import this type of resource? If import is possible how can I import my job schedule?


Solution

  • I was finally able to import my resource.

    The problem was the version of azurerm I was using.

    I was using a version much older than the latest one (3.95.0) and the way to import the resource was different.

    The correct command for me was the following:

    terraform import 'module.automation_account_powershell["eastus"].azurerm_automation_job_schedule.atm' /subscriptions/xxx/resourceGroups/rg-phoenix2cloud-pro-eastus/providers/Microsoft.Automation/automationAccounts/aa-eastus-pro/jobSchedules/e66a490b-6245-4530-a03f-904bfd293r78