terracognita icon indicating copy to clipboard operation
terracognita copied to clipboard

azurerm: Only allow import of policy_definitions and policy_set_definitions of type custom

Open marcoldp opened this issue 2 years ago • 0 comments

As of now terracognita imports all resources of type azurerm_policy_definitions and policy_set_definition, including the default ones (around 1k). This results in a longdelay to import terracognita resources for azurerm. Since most likely these resources don't need to be changed and the user won't want to import them, i think that only custom type resources should be imported by default.

This can be easily done by adding the following code to the corresponding functions at azurerm/resources.go

func policyDefinitions(ctx context.Context, a *azurerm, ar *AzureReader, resourceType 
....
for _, policyDefinition := range policyDefinitions {
// only adds policy definition type custom otherwise otherwise import all default ones
  if policyDefinition.DefinitionProperties.PolicyType == policy.TypeCustom {
    r := provider.NewResource(*policyDefinition.ID, resourceType, a)
    resources = append(resources, r)
  }
}

marcoldp avatar Jun 30 '22 15:06 marcoldp