cycloidio / terracognita

Reads from existing public and private cloud providers (reverse Terraform) and generates your infrastructure as code on Terraform configuration
MIT License
2.17k stars 163 forks source link

Modifying variable output name? #388

Open secretsoup opened 1 year ago

secretsoup commented 1 year ago

Is there a way to exclude certain strings from the exported variable/resource names? For example, it's pulling in the subscription ID into the variable names and making them incredibly long,

For example:

azurerm_availability_set__subscriptions_c6322bef1_a3de_4447_8asdf7_f32dbfa1_resourcegroups_prod_firewall_use_rg_providers_microsoft_compute_availabilitysets_prod_eastus_connectivity_pafw_platform_fault_domain_count = 2 azurerm_availability_set__subscriptions_c6322bef1_a3de_4447_8asdf7_f32dbfa1_resourcegroups_prod_firewall_use_rg_providers_microsoft_compute_availabilitysets_prod_eastus_connectivity_pafw_platform_update_domain_count = 5 azurerm_availability_set__subscriptions_c6322bef1_a3de_4447_8asdf7_f32dbfa1_resourcegroups_prod_firewall_use_rg_providers_microsoft_compute_availabilitysets_prod_eastus_connectivity_pafw_resource_group_name = "prod-firewall-use-rg" azurerm_availability_set__subscriptions_c6322bef1_a3de_4447_8asdf7_f32dbfa1_resourcegroups_prod_firewall_use_rg_providers_microsoft_compute_availabilitysets_prod_eastus_connectivity_pafw_tc_category = "compute" azurerm_lb__subscriptions_c6322bef1_a3de_4447_8asdf7_f32dbfa1_resourcegroups_prod_firewall_use_rg_providers_microsoft_network_loadbalancers_connectivity_elb_01_frontend_ip_configuration_0_name = "LoadBalancerFrontEnd" azurerm_lb__subscriptions_c6322bef1_a3de_4447_8asdf7_f32dbfa1_resourcegroups_prod_firewall_use_rg_providers_microsoft_network_loadbalancers_connectivity_elb_01_frontend_ip_configuration_0_private_ip_address_allocation = "Dynamic" azurerm_lb__subscriptions_c6322bef1_a3de_4447_8asdf7_f32dbfa1_resourcegroups_prod_firewall_use_rg_providers_microsoft_network_loadbalancers_connectivity_elb_01_frontend_ip_configuration_0_public_ip_address_id = "/subscriptions/c68b11/resourceGroups/prod-firewall-use-rg/providers/Microsoft.Network/publicIPAddresses/connectivity-elb-01-pip" azurerm_lb__subscriptions_c6322bef1_a3de_4447_8asdf7_f32dbfa1_resourcegroups_prod_firewall_use_rg_providers_microsoft_network_loadbalancers_connectivity_elb_01_frontend_ip_configuration_1_name = "AppGW-NonProd-Compliance-ARO" azurerm_lb__subscriptions_c6322bef1_a3de_4447_8asdf7_f32dbfa1_resourcegroups_prod_firewall_use_rg_providers_microsoft_network_loadbalancers_connectivity_elb_01_frontend_ip_configuration_1_private_ip_address_allocation = "Dynamic" azurerm_lb__subscriptions_c6322bef1_a3de_4447_8asdf7_f32dbfa1_resourcegroups_prod_firewall_use_rg_providers_microsoft_network_loadbalancers_connectivity_elb_01_frontend_ip_configuration_1_public_ip_address_id = "/subscriptions/c68b1ef/resourceGroups/prod-firewall-use-rg/providers/Microsoft.Network/publicIPAddresses/elb-appgw-nonprod-compliance-aro" azurerm_lb__subscriptions_c6322bef1_a3de_4447_8asdf7_f32dbfa1_resourcegroups_prod_firewall_use_rg_providers_microsoft_network_loadbalancers_connectivity_elb_01_frontend_ip_configuration_2_name = "DELETEME" azurerm_lb__subscriptions_c6322bef1_a3de_4447_8asdf7_f32dbfa1_resourcegroups_prod_firewall_use_rg_providers_microsoft_network_loadbalancers_connectivity_elb_01_frontend_ip_configuration_2_private_ip_address_allocation = "Dynamic"

Is there a way to strip out the subscription portion and subscription ID from the variable name?

xescugc commented 1 year ago

We actually have this in mind and want to fix it, we have https://github.com/cycloidio/terracognita/issues/275 opened for it and we want to try to find the best solution that still outputs "meaningful" variable names, basically trying to avoid something like: a_b_c_d or just allocation. But TBH the provider with longer names is always AzureRM so we may end up making a custom solution for it potentially.