andyt530 / py-az2tf Goto Github PK
View Code? Open in Web Editor NEWTool to automatically generate Terraform files for your Azure subscription
License: MIT License
Tool to automatically generate Terraform files for your Azure subscription
License: MIT License
I got this error after triyng ./az2tf.sh -s “id-sub” -v yes
Traceback (most recent call last):
File "../../scripts/az2tf.py", line 382, in <module>
azurerm_virtual_machine_extension.azurerm_virtual_machine_extension(crf,cde,crg,headers,requests,sub,json,az2tfmess,cldurl)
File "/py-az2tf/scripts/azurerm_virtual_machine_extension.py", line 52, in azurerm_virtual_machine_extension
ename=azr2[j]["name"]
IndexError: list index out of range
IndexError: list index out of range
Error in az2tf.py
The generated folder was created with many state .ft files but when I tried to type the next command ./az2tf.sh -s “[id_de_la_subscripcion_azure]” -f yes just it gots crashed
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 160, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 57, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/usr/local/lib/python3.6/socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 603, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 344, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 843, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 316, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 169, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f24e11c3d30>: Failed to establish a new connection: [Errno -3] Try again
During handling of the above exception, another exception occurred:
I tried to run the tool but this isnt working. This problem is from very long time almost from the month of march.
It would be great if anyone can fix it
I am getting the following error. It looks like it doesn't know how to properly treat backslashes in naming conventions.
Message:
Error: Invalid escape sequence
on azurerm_virtual_network.daze2-network-rg__dAZE2-Dev-vnet.tf line 17, in resource "azurerm_virtual_network" "daze2-network-rg__dAZE2-Dev-vnet":
17: "AppTaxonomy"="ITIS\Infrastructure\Dev"
The symbol "I" is not a valid escape sequence selector.
Awesome project -thanks
resource "azurerm_application_gateway"
backend_address_pool {
name = "be21"
fqdns = ["x.x.x.x"]
fqdns = ["x.x.x.x"]
Think this should be a list
the module azurerm_storage_account does not include the argument "default_value = Allow/Deny" when a network restriction is set to an account Causes immediate validation errors.
Deprication warnings exist as well with the following errors:
Warning: "zone_type": [DEPRECATED] Use the azurerm_private_dns_zone
resource instead.
Warning: "network_security_group_id": [DEPRECATED] Use the azurerm_subnet_network_security_group_association` resource instead.
Works wonerfully outside of that, thank you!
Hi,
great tool, thanks!
There seems to be a problem when handling apostrophes (can't vs cant):
~ description = "Can view CDN profiles and their endpoints, but can’t make changes." -> "Can view CDN profiles and their endpoints, but cant make changes."
While running "./az2tf.sh -s xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -v yes". I receive the following exception.
# azurerm_local_network_gateway 4
Traceback (most recent call last):
File "../../scripts/az2tf.py", line 326, in <module>
azurerm_local_network_gateway.azurerm_local_network_gateway(crf,cde,crg,headers,requests,sub,json,az2tfmess)
File "/home/kyle/py-az2tf/scripts/azurerm_local_network_gateway.py", line 70, in azurerm_local_network_gateway
fr.write('\t\t asn = "' + asn + '"\n')
TypeError: cannot concatenate 'str' and 'int' objects
TypeError: cannot concatenate 'str' and 'int' objects
Error in az2tf.py
Hi,
Am getting an error when trying to execute az2tf.sh script to generate tto terraform files.
Pasting the error below. I have just used this command. " ./az2tf.sh -s ".
ERROR BELOW:-
Traceback (most recent call last):
File "../../scripts/az2tf.py", line 385, in
azurerm_virtual_machine_scale_set.azurerm_virtual_machine_scale_set(crf,cde,crg,headers,requests,sub,json,az2tfmess,cldurl)
File "/usr/csuser/clouddrive/tf/az2tf/py-az2tf/scripts/azurerm_virtual_machine_scale_set.py", line 65, in azurerm_virtual_machine_scale_set
osvhd = azr[i]["properties"]["virtualMachineProfile"]["osProfile"]["linuxConfiguration"]["ssh"]["publicKeys"][0]["keyData"]
IndexError: list index out of range
IndexError: list index out of range
Error in az2tf.py
Please check and revert.
THanx
When importing my setup, az2tf replaces some names by some uuid:
~ resource "azurerm_role_definition" "roledefinitions__fd...f3" {
assignable_scopes = [
"/",
]
description = "Can read the attestation provider properties"
id = "/subscriptions/c0...4fc/providers/Microsoft.Authorization/roleDefinitions/fd...f3"
~ name = "Attestation Reader" -> "fd1bd22b-8476-40bc-a0bc-69b95687b9f3"
Thanks for the badass tool!
I was able to easily work around this by creating an alias, but just a note that on my machine, python2
doesn't resolve to anything, while python
resolves to v2.7 and python3
resolves to v3.7.3. Not sure it is safe to assume python2 exists with the variety of ways python could be installed/configured on MacOS (Homebrew, Apple Python, etc.).
Line 84 in 4dd204c
The file was generated by message is pointing to the wrong repo
# File generated by az2tf see: https://github.com/andyt530/az2tf
should be
# File generated by py-az2tf see: https://github.com/andyt530/py-az2tf
(Thanks for the awesome tool btw!)
Hi
GOt Invalid multi-line string error when executing az2tf script for a subscription. Please find attached import log for the same executed with debug output.
import.log
Thanx
Hi again Andy!!
I found and issue with the new functionality added to import app service slots, it seems to work well but when you write the name of the slot you don't write the app service's name so the output name of the slot is always the same for every app service, so after the first loop I got an error and its imposible to obtain the slots for every app service just I got just one app service completed, the importation ends normally but the output shows errors, when I look into the generated folder I saw the next files:
├── azurerm_app_service.yak__gx-yak-ms-accounting-firm.tf
├── azurerm_app_service.yak__gx-yak-ms-journal-entries.tf
├── azurerm_app_service.yak__gx-yak-ms-ledger-accounts.tf
├── azurerm_app_service.yak__gx-yak-ms-mig-coi.tf
├── azurerm_app_service.yak__gx-yak-ms-reports.tf
├── azurerm_app_service_slot.yak__dev.tf
├── azurerm_app_service_slot.yak__staging.tf
├── azurerm_app_service_slot.yak__test.tf
The correct name I think could be something like this:
├── azurerm_app_service.yak__gx-yak-ms-accounting-firm.tf
├── azurerm_app_service.yak__gx-yak-ms-journal-entries.tf
├── azurerm_app_service.yak__gx-yak-ms-ledger-accounts.tf
├── azurerm_app_service.yak__gx-yak-ms-mig-coi.tf
├── azurerm_app_service.yak__gx-yak-ms-reports.tf
├── azurerm_app_service_slot.yak__gx-yak-ms-accounting-firm_dev.tf
├── azurerm_app_service_slot.yak__gx-yak-ms-accounting-firm_staging.tf
├── azurerm_app_service_slot.yak__gx-yak-ms-accounting-firm_test.tf
├── azurerm_app_service.yak__gx-yak-ms-journal-entries_dev.tf
├── azurerm_app_service.yak__gx-yak-ms-journal-entries_staging.tf
├── azurerm_app_service.yak__gx-yak-ms-journal-entries_test.tf
├── azurerm_app_service.yak__gx-yak-ms-ledger-accounts_dev.tf
├── azurerm_app_service.yak__gx-yak-ms-ledger-accounts_staging.tf
├── azurerm_app_service.yak__gx-yak-ms-ledger-accounts_test.tf
...
...
...
I downloaded the repo, unzipped to an empty directory, CDed to the directory that had the az2tf.sh script, and issued the following command:
./az2tf.sh -s mysubsciptionid -g mygroupdname -v yes
I got:
Subscription ID = myssubscriptionid
Azure Resource Group Filter = mygroupsname
Terraform Resource Type Filter =
Get Subscription Policies & RBAC = no
Extract Key Vault Secrets to .tf files (insecure) = no
Fast Forward = no
Validate Only = yes
Debug = no
python2.7 ../../scripts/az2tf.py -s 3fde759f-01ac-48dd-b16b-885608b2be16 -g wase 2>&1 | tee -a import.log
Traceback (most recent call last):
File "../../scripts/az2tf.py", line 4, in
import requests
ImportError: No module named requests
ImportError: No module named requests
Error in az2tf.py
Thanks for the tool!! I am new to terraform and was referred here. I am attempting to use this tool in the Azure Government sector specifically usdodeast and I ran into a python error.
ENV details:
OS: CentOS 7.6
Package Versions:
azure-cli v2.0.71
Terraform v0.12.7
Python v2.7.5
export ARM_ENVIRONMENT=usgovernment
python2.7 ../../scripts/az2tf.py -s <subscriptionID> 2>&1 | tee -a import.log
Traceback (most recent call last):
File "../../scripts/az2tf.py", line 4, in <module>
import requests
ImportError: No module named requests
ImportError: No module named requests
Error in az2tf.py
IOError: [Errno 36] File name too long: u'azurerm_network_security_group.citrix-xd-0feb107a-80db-493a-8ea0-3da8bca85a47-kebbz__Citrix-Deny-All-a3pgu-0feb107a-80db-493a-8ea0-3da8bca85a47.tf'
IOError: [Errno 36] File name too long: u'azurerm_network_security_group.citrix-xd-0feb107a-80db-493a-8ea0-3da8bca85a47-kebbz__Citrix-Deny-All-a3pgu-0feb107a-80db-493a-8ea0-3da8bca85a47.tf'
Error in az2tf.py
Any reasonable way to bypass this? thank you.
HI
When running az2tf.sh -v yes hitting the following error
Traceback (most recent call last):
File "../../scripts/az2tf.py", line 298, in
azurerm_managed_disk.azurerm_managed_disk(crf,cde,crg,headers,requests,sub,json,az2tfmess)
File "/home/dooret/py-az2tf/scripts/azurerm_managed_disk.py", line 135, in azurerm_managed_disk
fr.write('\t "' + key + '"="' + tval + '"\n')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 31: ordinal not in range(128)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 31: ordinal not in range(128)
Error in az2tf.py
running this from Windows 10 1903 using the Azure CLI I get the following error, verified Python 2.7 exists
bash: az: command not found
Subscription ID = Redacted
Azure Resource Group Filter =
Terraform Resource Type Filter =
Get Subscription Policies & RBAC = no
Extract Key Vault Secrets to .tf files (insecure) = no
Fast Forward = no
Validate Only = yes
Debug = no
python2.7 ../../scripts/az2tf.py -s SubScription>&1 | tee -a import.log
bash: python2.7: command not found
Unable to get around this issue.
Traceback (most recent call last):
File "../../scripts/az2tf.py", line 333, in
azurerm_application_gateway.azurerm_application_gateway(crf,cde,crg,headers,requests,sub,json,az2tfmess)
File "/home/platforms/az2tf/py-az2tf/scripts/azurerm_application_gateway.py", line 199, in azurerm_application_gateway
fr.write('\t host_name = "' + bhn + '"\n')
TypeError: cannot concatenate 'str' and 'NoneType' objects
TypeError: cannot concatenate 'str' and 'NoneType' objects
Error in az2tf.py
Package Versions:
azure-cli 2.0.72
Terraform v0.12.9
Python 2.7.15+
Terraform Resource Type Filter =
Get Subscription Policies & RBAC = no
Extract Key Vault Secrets to .tf files (insecure) = no
Fast Forward = no
Validate Only = no
Debug = no
python2.7 ../../scripts/az2tf.py -s 8c2a2cbd-6bdc-4094-bfa1-8ca3b7f2c7ea -g wavy-whatsapp 2>&1 | tee -a import.log
resource group=wavy-whatsapp
Get Access Token from CLI
Subscription: 8c2a2cbd-6bdc-4094-bfa1-8ca3b7f2c7ea
Found subscription 8c2a2cbd-6bdc-4094-bfa1-8ca3b7f2c7ea proceeding ...
Found Resource Groupwavy-whatsapp
# azurerm_resource_group 4
# azurerm_management_lock 0
# azurerm_user_assigned_identity 1
rgname=mc_wavy-whatsapp_wavy-aks-whatsapp-single_eastus2 crg=wavy-whatsapp
# azurerm_availability_set 0
# azurerm_route_table 0
# azurerm_application_security_group 0
# azurerm_network_security_group 2
# azurerm_virtual_network 1
# azurerm_subnet 1
# azurerm_virtual_network_peering 1
# azurerm_key_vault 0
# azurerm_managed_disk 0
# azurerm_storage_account 2
# azurerm_public_ip 2
# azurerm_traffic_manager_profile 0
# azurerm_traffic_manager_endpoint 0
# azurerm_network_interface 0
# azurerm_dns_zone 0
# azurerm_lb 2
# azurerm_lb_nat_rule 2
# azurerm_lb_nat_pool 2
# azurerm_lb_backend_address_pool 2
# azurerm_lb_probe 2
# azurerm_lb_rule 2
# azurerm_application_gateway 1
# azurerm_local_network_gateway 0
# azurerm_virtual_network_gateway 0
# azurerm_virtual_network_gateway_connection 0
# azurerm_express_route_circuit 0
# azurerm_express_route_circuit_authorization 0
# azurerm_express_route_circuit_peering 0
# azurerm_container_registry 0
# azurerm_kubernetes_cluster 1
# azurerm_recovery_services_vault 0
# azurerm_virtual_machine 0
# azurerm_virtual_machine_extension 0
# azurerm_virtual_machine_scale_set 1
# azurerm_automation_account 0
# azurerm_log_analytics_workspace 1
# azurerm_log_analytics_solution 1
# azurerm_image 0
# azurerm_shared_image_gallery 0
# azurerm_snapshot 0
# azurerm_network_watcher 2
# azurerm_cosmosdb_account 0
# azurerm_sql_server 0
# azurerm_sql_database 0
# azurerm_databricks_workspace 0
# azurerm_app_service_plan 0
# azurerm_app_service 0
# azurerm_function_app 0
# azurerm_logic_app_workflow 0
# azurerm_api_management 0
# azurerm_monitor_autoscale_setting 0
terraform init
There are some problems with the configuration, described below.
The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.
Error: Invalid multi-line string
on azurerm_kubernetes_cluster.wavy-whatsapp__wavy-aks-whatsapp-single.tf line 11, in resource "azurerm_kubernetes_cluster" "wavy-whatsapp__wavy-aks-whatsapp-single":
11:
12:
Quoted strings may not be split over multiple lines. To produce a multi-line
string, either use the \n escape to represent a newline character or use the
"heredoc" multi-line template syntax.
Error: Unterminated template string
on azurerm_kubernetes_cluster.wavy-whatsapp__wavy-aks-whatsapp-single.tf line 11, in resource "azurerm_kubernetes_cluster" "wavy-whatsapp__wavy-aks-whatsapp-single":
11:
12:
No closing marker was found for the string.
Error: Invalid multi-line string
Error: Unterminated template string
Error with terraform init
When importing my setup, a settings
attribute is missing:
# azurerm_virtual_machine_extension.mc_xyz-dev_xyz-dev_westeurope__aks-agentpool-13954513-0__computeAksLinuxBilling will be updated in-place
~ resource "azurerm_virtual_machine_extension" "mc_xyz-dev_xyz-dev_westeurope__aks-agentpool-13954513-0__computeAksLinuxBilling" {
auto_upgrade_minor_version = true
+ settings = jsonencode({})
}
Thanks for this great tool. I'm just starting to learn Terraform and have used this tool to create TF files for some resources already provisioned into our tenant by a previous employee. I'm trying to run it today on some PaaS applications, it could be that this error is related to an unsupported resource but I don't understand the python code enough yet to know! This is being run on the Terraform marketplace image, created today and AZ2TF was freshly cloned onto it.
python2.7 ../../scripts/az2tf.py -s 2>&1 | tee -a import.log
Get Access Token from CLI
Subscription:
Found subscription proceeding ...
Traceback (most recent call last):
File "../../scripts/az2tf.py", line 277, in
azurerm_management_lock.azurerm_management_lock(crf,cde,crg,headers,requests,sub,json,az2tfmess)
File "/home/stsadmin/py-az2tf/scripts/azurerm_management_lock.py", line 67, in azurerm_management_lock
fr.write('\t notes = "'+ notes + '"\n')
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 74: ordinal not in range(128)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 74: ordinal not in range(128)
Error in az2tf.py
Hi
Are there any plans to adjust this I'm manually changing it for now but it would be great if the module would create these.
Thanks
Tony
I tried to run this tool but getting below error.
nithin@Azure:~/py-az2tf$ ./az2tf.sh -s xxxxxxxxxxxxxxxxxxxxxxxxxxxxx-v yes
Subscription ID = xxxxxxxxxxxxxxxxxxxxxxxx
Azure Resource Group Filter =
Terraform Resource Type Filter =
Get Subscription Policies & RBAC = no
Extract Key Vault Secrets to .tf files (insecure) = no
Fast Forward = no
Validate Only = yes
Debug = no
python2.7 ../../scripts/az2tf.py -s XXXXXXXXXXXXXXXXXXXX 2>&1 | tee -a import.log
Traceback (most recent call last):
File "../../scripts/az2tf.py", line 4, in
import requests
ImportError: No module named requests
ImportError: No module named requests
Error in az2tf.py
Az cli version = 2.0.74 (installed on WSL2/Ubuntu)
Terraform = 0.12.9 (linux)
OS = WSL2 on Windows 10 (Ubuntu 18.04)
Traceback (most recent call last):
File "../../scripts/az2tf.py", line 337, in <module>
azurerm_virtual_network_gateway.azurerm_virtual_network_gateway(crf,cde,crg,headers,requests,sub,json,az2tfmess)
File "/mnt/c/github/py-az2tf/scripts/azurerm_virtual_network_gateway.py", line 53, in azurerm_virtual_network_gateway sku=azr[i]["properties"]["sku"]["name"]
KeyError: 'sku'
KeyError: 'sku'
Error in az2tf.py
The azr
variable in the file azurerm_virtual_network_gateway.py
shows no sub-property under 'properties' for the gateway that has a basic SKU.
Confirmed that az cli returns the SKU with value Basic
az network vnet-gateway show -n gw-Resource-EastUS2 -g resourcegroupname
this returns
"resourceGuid": "447f57f0-e5bd-4b1e-ae16-2716a32a542e",
"sku": {
"capacity": 2,
"name": "Basic",
"tier": "Basic"
},
Tried changing the API version to : params = {'api-version': '2019-07-01'}
Same issue persists.
Since sku is null
the below gives a keyError
azr[2]["properties"]["sku"]
This could be related to Python SDK for Azure or the requests
module in Python.
Seems to be an issue with some of the terraform files when doing a validate.
Ubuntu-18.04
Terraform v0.12.9
azure-cli 2.0.73
The resource Type and Name are missing been surrounded by ""
Error: Missing name for resource
Error: Invalid block definition
Error: Missing name for resource
Error: Invalid block definition
Error: Missing name for resource
-azurerm_managed_disk
Error: Invalid block definition
Error: Missing name for resource
-azurerm_network_interface
Error: Invalid block definition
Error: Missing name for resource
Error: Invalid block definition
Error: Missing name for resource
Error: Invalid block definition
Error: Missing name for resource
Error: Invalid block definition
Error: Missing name for resource
Error: Invalid block definition
Error: Missing name for resource
Error: Invalid block definition
Error: Missing name for resource
Error: Invalid block definition
Error: Missing name for resource
Error: Invalid block definition
Error: Missing name for resource
Error: Invalid block definition
Error: Missing name for resource
Error: Invalid block definition
Error: Missing name for resource
Error: Invalid block definition
Error: Invalid resource name
Error: Invalid resource name
Error: Invalid resource name
Error: Missing name for resource
Error: Invalid block definition
Error: Missing name for resource
Error: Invalid block definition
Error: Missing name for resource
Error: Invalid block definition
Error: Missing name for resource
Error: Invalid block definition
Error: Missing name for resource
Error: Invalid block definition
Error: Invalid resource name
Error: Invalid resource name
Error: Invalid resource name
Error: Invalid resource name
Error: Missing name for resource
Error: Invalid block definition
Error: Missing name for resource
Error: Invalid block definition
Error: Missing name for resource
Error: Invalid block definition
Error: Missing name for resource
Error: Invalid block definition
Error with terraform init
I have
data "azurerm_subscription" "current" {}
resource "azurerm_management_lock" "subscription-level" {
...
notes = "Items can't be deleted in the "Group" Subscription"
}
which results in An argument definition must end with a newline.
Trying the quickstart and ran in one of those error that you requested to be logged. I hope this will help you:
root@14042f86dee0:~/py-az2tf# ./az2tf.sh -s 2de839a0-37f9-4163-a32a-e1bdb8d6eb7e -v yes
Subscription ID = 2de839a0-37f9-4163-a32a-e1bdb8d6eb7e
Azure Resource Group Filter =
Terraform Resource Type Filter =
Get Subscription Policies & RBAC = no
Extract Key Vault Secrets to .tf files (insecure) = no
Fast Forward = no
Validate Only = yes
Debug = no
python2.7 ../../scripts/az2tf.py -s 2de839a0-37f9-4163-a32a-e1bdb8d6eb7e 2>&1 | tee -a import.log
Get Access Token from CLI
Subscription: 2de839a0-37f9-4163-a32a-e1bdb8d6eb7e
Found subscription 2de839a0-37f9-4163-a32a-e1bdb8d6eb7e proceeding ...
# azurerm_resource_group 7
# azurerm_management_lock 0
# azurerm_user_assigned_identity 0
# azurerm_availability_set 0
# azurerm_route_table 0
# azurerm_application_security_group 0
# azurerm_network_security_group 0
# azurerm_virtual_network 4
# azurerm_subnet 4
# azurerm_virtual_network_peering 4
# azurerm_key_vault 0
# azurerm_managed_disk 3
# azurerm_storage_account 0
# azurerm_public_ip 0
# azurerm_traffic_manager_profile 0
# azurerm_traffic_manager_endpoint 0
# azurerm_network_interface 3
# azurerm_dns_zone 0
# azurerm_lb 0
# azurerm_lb_nat_rule 0
# azurerm_lb_nat_pool 0
# azurerm_lb_backend_address_pool 0
# azurerm_lb_probe 0
# azurerm_lb_rule 0
# azurerm_application_gateway 0
# azurerm_local_network_gateway 0
# azurerm_virtual_network_gateway 0
# azurerm_virtual_network_gateway_connection 0
# azurerm_express_route_circuit 0
# azurerm_express_route_circuit_authorization 0
# azurerm_express_route_circuit_peering 0
# azurerm_container_registry 0
# azurerm_kubernetes_cluster 0
# azurerm_recovery_services_vault 0
# azurerm_virtual_machine 3
# azurerm_virtual_machine_extension 3
# azurerm_virtual_machine_scale_set 0
# azurerm_automation_account 0
# azurerm_log_analytics_workspace 0
# azurerm_log_analytics_solution 0
# azurerm_image 0
# azurerm_shared_image_gallery 0
# azurerm_snapshot 0
# azurerm_network_watcher 1
# azurerm_cosmosdb_account 0
# azurerm_sql_server 0
# azurerm_sql_database 0
# azurerm_databricks_workspace 0
# azurerm_app_service_plan 0
# azurerm_app_service 0
# azurerm_function_app 0
# azurerm_logic_app_workflow 0
# azurerm_api_management 0
# azurerm_monitor_autoscale_setting 0
terraform init
There are some problems with the configuration, described below.
The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.
Error: Error parsing /root/py-az2tf/generated/tf.2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/azurerm_virtual_machine_extension.hub-vnet-rg__hub-vm__OmsAgentForLinux.tf: At 11:12: Unknown token: 11:12 IDENT jsonencode
Error: Error parsing /root/py-az2tf/generated/tf.2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/azurerm_virtual_machine_extension.hub-vnet-rg__hub-vm__OmsAgentForLinux.tf: At 11:12: Unknown token: 11:12 IDENT jsonencode
Error with terraform init
First, thanks a lot for this tool.
Is there any plan to generate Terraform configuration files from Azure Event Hubs?
Thanks in advance
Hello,
The script hangs on a type conversion error at several steps, I'm summing it up here :
azurerm_virtual_network_gateway_connection.py, line 127 & 128 -> TypeError: cannot concatenate 'str' and 'int' objects
azurerm_express_route_circuit_peering.py, line 78 -> TypeError: cannot concatenate 'str' and 'list' objects
Each time solved by using str function in the print statement (might not be the solution but in order to move one step further it helps).
Another one easily fixed in the latter, line 74, it should be :
if pt == "MicrosoftPeering" or pt == "AzurePrivatePeering":
instead of
if pt == "MicrosoftPeering" or "pt" == "AzurePrivatePeering":
After that, it fails validation :
Error: Argument or block definition required
on azurerm_express_route_circuit_peering.network-prod-rg__AzurePrivatePeering.tf line 13, in resource "azurerm_express_route_circuit_peering" "network-prod-rg__AzurePrivatePeering":
An argument or block definition is required here.
The tf file (real info obfuscated obviously):
resource azurerm_express_route_circuit_peering network-prod-rg__AzurePrivatePeering {
resource_group_name = "some-rg"
peering_type = "AzurePrivatePeering"
express_route_circuit_name = "some-circuit"
primary_peer_address_prefix = "xxxxxx/30"
secondary_peer_address_prefix = "xxxxxx/30"
vlan_id = "xx"
peer_asn = "xxxx"
microsoft_peering_config {
advertised_public_prefixes = "[]"
}
Maybe more a terraform issue, I haven't been able to find a reference for AzurePrivatePeering.
Tx
I'm not a Python programmer, and this is a new MacBook so I had to install a ton of prerequisites. However, I've used az2tf successfully before. This is the latest version of pretty much everything.
Traceback output:
./az2tf.sh -s redacted -p yes
Subscription ID = redacted
Azure Resource Group Filter =
Terraform Resource Type Filter =
Get Subscription Policies & RBAC = yes
Extract Key Vault Secrets to .tf files (insecure) = no
Fast Forward = no
Validate Only = no
Debug = no
python2.7 ../../scripts/az2tf.py -s redacted -p yes 2>&1 | tee -a import.log
Policies & RBAC=yes
Get Access Token from CLI
Subscription: redacted
Found subscription redacted proceeding ...
Traceback (most recent call last):
File "../../scripts/az2tf.py", line 272, in module
azurerm_policy_definition.azurerm_policy_definition(crf,cde,crg,headers,requests,sub,json,az2tfmess)
File "/Users/aa681787/apps/azure/terraform/py-az2tf/py-az2tf/scripts/azurerm_policy_definition.py", line 78, in azurerm_policy_definition
prules=str(ast.literal_eval(json.dumps(azr[i]["properties"]["policyRule"])))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 80, in literal_eval
return _convert(node_or_string)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 63, in _convert
in zip(node.keys, node.values))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 62, in
return dict((_convert(k), _convert(v)) for k, v
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 63, in _convert
in zip(node.keys, node.values))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 62, in
return dict((_convert(k), _convert(v)) for k, v
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 60, in _convert
return list(map(_convert, node.elts))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 63, in _convert
in zip(node.keys, node.values))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 62, in
return dict((_convert(k), _convert(v)) for k, v
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 79, in _convert
raise ValueError('malformed string')
ValueError: malformed string
raise ValueError('malformed string')
ValueError: malformed string
Error in az2tf.py
Ran this command after cloning the repo and installing the pre-req's: ./az2tf.sh -s '[redactedSubID]' -v yes
Received this Python error:
Subscription ID = [redactedSubID]
Azure Resource Group Filter =
Terraform Resource Type Filter =
Get Subscription Policies & RBAC = no
Extract Key Vault Secrets to .tf files (insecure) = no
Fast Forward = no
Validate Only = yes
Debug = no
python2.7 ../../scripts/az2tf.py -s [redactedSubID] 2>&1 | tee -a import.log
Traceback (most recent call last):
File "../../scripts/az2tf.py", line 4, in <module>
import requests
ImportError: No module named requests
ImportError: No module named requests
Error in az2tf.py
Hi everyone
I do get the following error:
4
Traceback (most recent call last):
File "../../scripts/az2tf.py", line 367, in
azurerm_virtual_network_gateway_connection.azurerm_virtual_network_gateway_connection(crf,cde,crg,headers,requests,sub,json,az2tfmess,cldurl)
File "/home/philippe/py-az2tf-master/scripts/azurerm_virtual_network_gateway_connection.py", line 104, in azurerm_virtual_network_gateway_connection
fr.write('\t peer_virtual_network_gateway_id = azurerm_virtual_network_gateway.' + peerrg +'__' + peernam + '.id\n')
UnboundLocalError: local variable 'peerrg' referenced before assignment
UnboundLocalError: local variable 'peerrg' referenced before assignment
Error in az2tf.py
Cheers Philippe
Azurerm2.0 requires extra field to be present in provider section
provider "azurerm" {
version = ">= 1.40.0"
}
vs
provider "azurerm" {
version = ">= 2.0.0"
features {
}
}
Validation fails without that.
Initializing provider plugins...
- Checking for available provider plugins...
- Downloading plugin for provider "azurerm" (hashicorp/azurerm) 2.0.0...
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
terraform validate
Error: "features": required field is not set
Error Validating
Had an issue with exporting an environment with a traffic manager endpoint using app service as an endpoint:
Error: Reference to undeclared resource
on azurerm_traffic_manager_endpoint.access2__DMSQA.tf line 11, in resource "azurerm_traffic_manager_endpoint" "access2__DMSQA":
11: target_resource_id = azurerm_public_ip.access2__access2qa.id
A managed resource "azurerm_public_ip" "access2__access2qa" has not been
declared in the root module.
When I manually export that resource I get a different target resource id:
target_resource_id = "/subscriptions/{SubID}/resourceGroups/{resource group}/providers/Microsoft.Web/sites/{app service}"
As far as I can tell the dev branch hasn't been updated in about 11 months. Has anyone had any success using this tool lately? Is this project now dead? Has it been superseded?
As deadline date is approaching supporting python3 would be useful
Attempted to use this with Azure China, but received errors that it couldn't find the tenant or subscription specified. Dove into the code a bit, and looks like the API URL is hard-coded as https://management.azure.com/... in several places. Would probably be good to map this url value to an input parameter looking for "AzureCloud", "AzureChinaCloud", "AzureUSGovernment", or "AzureGermanCloud" - matching az cli.
Great job -- I was not expecting to find anyone masochistic enough to start on this, but lo and behold, there you were :)
In my excitement to race ahead, I overlooked your version 11.11 requirement (latest is 11.14 as of this writing, I'll assume you just mean 11.x) and ran it with 12.x installed. It actually worked until it got to validate, and the only thing it complained about were the tags I'd assigned to my resources:
Error: Unsupported block type
on azurerm_resource_group__ccma-qa-resources.tf line 4, in resource "azurerm_resource_group" "ccma-qa-resources":
4: tags {
Blocks of type "tags" are not expected here. Did you mean to define argument
"tags"? If so, use the equals sign to assign it a value.
This doesn't seem like a huge issue - any chance of realigning the rebirth of this project in pyhton with a v12 dependency so as to not get left in the sunset? If not, that's okay - but perhaps you could direct me as to where I should look to hack this in myself to emit v12 compatible tag schema?
az cli 2.0.74
Terraform 0.12.9
OS: WSL2 - Ubuntu 18.04
command used: ./az2tf.sh -s 8cfbd600-1193-40e4-8a27-xxxxxxxxx -d yes -f yes -v yes
Description: The script fails when it reaches the express route stage.
# azurerm_express_route_circuit_peering 1
{
"sku": {
"tier": "Premium",
"name": "Premium_MeteredData",
"family": "MeteredData"
},
"name": "xx_to_Azure_EAST_PROD2",
"id": "/subscriptions/oood600-1193-40e4-8a27-xxxxxxxx/resourceGroups/ExpressRouteUSeast/providers/Microsoft.Network/expressRouteCircuits/xto_Azure_EAST_PROD2",
"etag": "W/\"d53cc9b8-7434-49cf-8aa4-eac50404856f\"",
"location": "eastus",
"type": "Microsoft.Network/expressRouteCircuits",
"properties": {
"provisioningState": "Succeeded",
"circuitProvisioningState": "Enabled",
"authorizations": [],
"serviceProviderProvisioningState": "NotProvisioned",
"gatewayManagerEtag": "",
"serviceProviderProperties": {
"serviceProviderName": "Verizon",
"bandwidthInMbps": 100,
"peeringLocation": "Washington DC"
},
"allowClassicOperations": false,
"serviceKey": "xxxxxxx-afb8-7ffb9b290723",
"peerings": [],
"resourceGuid": "xxxxxxxxxxxx-a98a-d31d3413615b"
}
}
Traceback (most recent call last):
File "../../scripts/az2tf.py", line 345, in <module>
azurerm_express_route_circuit_peering.azurerm_express_route_circuit_peering(crf,cde,crg,headers,requests,sub,json,az2tfmess)
File "/mnt/c/github/py-az2tf/scripts/azurerm_express_route_circuit_peering.py", line 91, in azurerm_express_route_circuit_peering fr.write('}\n')
UnboundLocalError: local variable 'fr' referenced before assignment
UnboundLocalError: local variable 'fr' referenced before assignment
Error in az2tf.py
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.