hashicorp / terraform-cdk

Define infrastructure resources using programming constructs and provision them using HashiCorp Terraform
https://www.terraform.io/cdktf
Mozilla Public License 2.0
4.8k stars 443 forks source link

`azurerm` provider: Python package cdktf-cdktf-provider-azurerm extremely slow to import #2792

Closed james-mwakichako closed 11 months ago

james-mwakichako commented 1 year ago

We are currently using the azurerm provider to create terraform resources. We have noticed that importing the specific resources takes ~ 45 seconds which is slowing our processes down.

Community Note

cdktf & Language Versions

cdktf - 0.15.5
python - 3.10.9
Terraform - v1.4.3-dev

Affected Provider / Resource(s)

azurerm python Pre-Built Provider : cdktf-cdktf-provider-azurerm = "5.0.13"

Debug Output

Expected Behavior

importing the package within a python file should be fast.

Actual Behavior

importing cdktf-cdktf-provider-azurerm take about 45 seconds to complete.

Steps to Reproduce

Below is the source code.

from constructs import Construct
from cdktf import TerraformStack, App
from cdktf_cdktf_provider_azurerm.provider import AzurermProvider

class TestStack(TerraformStack):
    def __init__(self, scope: Construct, id: str):
        super().__init__(scope, id)

        AzurermProvider(self, "azurerm", features={})

Important Factoids

On running importtime against our script, here is what we found:

import time:   9501138 |    9501138 |               cdktf_cdktf_provider_azurerm._jsii
import time:        26 |   54269769 |           cdktf_cdktf_provider_azurerm.provider

Are there any workarounds to speed up import time ?

github-actions[bot] commented 10 months ago

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've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.