Skip to content

AZtfexport - problem with big subscriptions #663

Description

@rafall92

Hi
I try to do full export of all azure subscriptions in my tenant. I prepared script which perform export, and commit HCL files on github repository. Each of subscription has its own repo, so we run this script by github action. I use powershell parrarelism, so i run export for all of RG at once.
Unfortunately, some of them are big, Not because a lot of RG, but because of lots of resources. In one subscription we have aprox. 10k of resources, so exporting them takes a lot of time(more than 6 hours), so we hit github action limit. We decide to move this export to separate machine, and export many subscriptions at once. I try to do that with 2 subscriptions, and got this errors.

Error: initializing provider for the import directories: 5 errors occurred:
	* task error: error running terraform init: exit status 0xffffffff
	* task error: error running terraform init: exit status 0xffffffff
	* task error: error running terraform init: exit status 0xffffffff
	* task error: error running terraform init: exit status 0xffffffff
	* task error: error running terraform init: exit status 0xffffffff

Each of export has its own workDir, i use default pararel value(not using parameter, so stay at default value of 10). Is there any tips how can i handle my problem, or how can i decrese execution time? I don't need state, only HCL

This is part of code responsible for export

$resourceGroups = Get-AzResourceGroup

$resourceGroups | ForEach-Object {
    $rgName = $_.ResourceGroupName

    $exportPath = Join-Path -Path $Using:backupARMPath -ChildPath $Using:rgName | Join-Path -ChildPath "$resName.json"

    aztfexport resource-group --non-interactive `
        --subscription-id $subscriptionId `
        --output-dir $exportPath `
        --hcl-only=true `
        --append=false `
        --plain-ui `
        --exclude-azure-resource "secrets" `
        --exclude-azure-resource "systemTopics" `
        --exclude-azure-resource "certificates" `
        --exclude-azure-resource "listClusterUserCredential" `
        --exclude-azure-resource "tables/WADDiagnosticInfrastructureLogsTable" `
        --exclude-azure-resource "tables/WADMetricsPT1MP10DV2S20241010" `
        --exclude-azure-resource "tables/WADPerformanceCountersTable" `
        --exclude-azure-resource "virtualMachines/azure-*" `
        $rgName 2>&1 | Tee-Object -Variable result
} -ThrottleLimit 4

And I run this script for 2 subscriptions at once

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions