Comments (9)
Hi,
Could you post the contents of the file azurerm_virtual_machine_extension.hub-vnet-rg__hub-vm__OmsAgentForLinux.tf here please
from py-az2tf.
Hello Andy,
Tried to re-create the issue but things must have changed in the subscription. It is no longer tripping on the OmsAgentForLinux. I lost the tf file as I was running from a docker container that was configured to deleted itself on exit. Sorry.
from py-az2tf.
On the other hand I am now running in a different issue:
root@7b6f484f3559:~/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 19
# azurerm_management_lock 0
# azurerm_user_assigned_identity 0
# azurerm_availability_set 0
# azurerm_route_table 5
Traceback (most recent call last):
File "../../scripts/az2tf.py", line 284, in <module>
azurerm_route_table.azurerm_route_table(crf,cde,crg,headers,requests,sub,json,az2tfmess)
File "/root/py-az2tf/scripts/azurerm_route_table.py", line 26, in azurerm_route_table
loc=azr[i]["location"]
KeyError: 'location'
KeyError: 'location'
Error in az2tf.py
I have started to deploy some resources in the subscription using terraform and if I leave those resources in the subscription py-az2tf is giving the error above.
If a terraform destroy those resources it work fine.
If I look in the subscription there is only 3 route-tables but somehow py-az2tf report 5 as can be seen in the log above... look like why it is complaining of the two location KeyError.
from py-az2tf.
In case this help... I added a "print azr" after line 11 in azure-route-table.py to see what was being parsed and got this:
[{u'properties': {u'routes': [{u'properties': {u'addressPrefix': u'0.0.0.0/0', u'nextHopType': u'Internet', u'provisioningState': u'Succeeded'}, u'etag': u'W/"f57ee8ff-bd89-4aca-99bc-77cea5e52edc"', u'type': u'Microsoft.Network/routeTables/routes', u'name': u'FirewallDefaultRoute', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/Demo-Infra-NetCore-RG/providers/Microsoft.Network/routeTables/AzureFirewall_Demo-Infra-NetCore-VNET-msfirewall/routes/FirewallDefaultRoute'}], u'resourceGuid': u'01394bd3-d4fb-4dc0-8eed-fa4235b5c6fc', u'disableBgpRoutePropagation': False, u'provisioningState': u'Succeeded'}, u'etag': u'W/"f57ee8ff-bd89-4aca-99bc-77cea5e52edc"', u'type': u'Microsoft.Network/routeTables', u'name': u'AzureFirewall_Demo-Infra-NetCore-VNET-msfirewall', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/Demo-Infra-NetCore-RG/providers/Microsoft.Network/routeTables/AzureFirewall_Demo-Infra-NetCore-VNET-msfirewall'}, {u'properties': {u'routes': [{u'properties': {u'addressPrefix': u'0.0.0.0/0', u'nextHopType': u'Internet', u'provisioningState': u'Succeeded'}, u'etag': u'W/"90280ce0-cadd-43b1-82a0-7e457c0704e9"', u'type': u'Microsoft.Network/routeTables/routes', u'name': u'FirewallDefaultRoute', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/DND-Infra-NetCore-RG/providers/Microsoft.Network/routeTables/AzureFirewall_DND-Infra-NetCore-VNET-msfirewall/routes/FirewallDefaultRoute'}], u'resourceGuid': u'5a09ff50-5102-4406-84c9-6ad7f8e66c8e', u'disableBgpRoutePropagation': False, u'provisioningState': u'Succeeded'}, u'etag': u'W/"90280ce0-cadd-43b1-82a0-7e457c0704e9"', u'type': u'Microsoft.Network/routeTables', u'name': u'AzureFirewall_DND-Infra-NetCore-VNET-msfirewall', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/DND-Infra-NetCore-RG/providers/Microsoft.Network/routeTables/AzureFirewall_DND-Infra-NetCore-VNET-msfirewall'}, {u'name': u'PwPT-MGMT-APP-RT', u'tags': {u'Organizations': u'PwP0-CCC-E&O', u'DeploymentVersion': u'2018-12-14-01', u'Classification': u'Unclassified', u'Enviroment': u'Sandbox', u'CostCenter': u'PwP0-EA', u'Owner': u'[email protected]'}, u'properties': {u'routes': [{u'properties': {u'addressPrefix': u'100.96.122.0/24', u'nextHopType': u'VnetLocal', u'provisioningState': u'Succeeded'}, u'etag': u'W/"99c971ed-86a1-480e-b0f5-d9069b025cb8"', u'type': u'Microsoft.Network/routeTables/routes', u'name': u'local-Subnet', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/routeTables/PwPT-MGMT-APP-RT/routes/local-Subnet'}, {u'properties': {u'addressPrefix': u'100.96.120.0/21', u'nextHopType': u'VirtualAppliance', u'nextHopIpAddress': u'100.96.116.4', u'provisioningState': u'Succeeded'}, u'etag': u'W/"99c971ed-86a1-480e-b0f5-d9069b025cb8"', u'type': u'Microsoft.Network/routeTables/routes', u'name': u'PwPT-MGMT-VNET', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/routeTables/PwPT-MGMT-APP-RT/routes/PwPT-MGMT-VNET'}, {u'properties': {u'addressPrefix': u'100.96.116.64/27', u'nextHopType': u'VirtualAppliance', u'nextHopIpAddress': u'100.96.116.4', u'provisioningState': u'Succeeded'}, u'etag': u'W/"99c971ed-86a1-480e-b0f5-d9069b025cb8"', u'type': u'Microsoft.Network/routeTables/routes', u'name': u'PwPT-Management', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/routeTables/PwPT-MGMT-APP-RT/routes/PwPT-Management'}, {u'properties': {u'addressPrefix': u'100.96.112.0/21', u'nextHopType': u'VirtualAppliance', u'nextHopIpAddress': u'100.96.116.4', u'provisioningState': u'Succeeded'}, u'etag': u'W/"99c971ed-86a1-480e-b0f5-d9069b025cb8"', u'type': u'Microsoft.Network/routeTables/routes', u'name': u'PwPT-Core-VNET', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/routeTables/PwPT-MGMT-APP-RT/routes/PwPT-Core-VNET'}, {u'properties': {u'addressPrefix': u'0.0.0.0/0', u'nextHopType': u'VirtualAppliance', u'nextHopIpAddress': u'100.96.116.4', u'provisioningState': u'Succeeded'}, u'etag': u'W/"99c971ed-86a1-480e-b0f5-d9069b025cb8"', u'type': u'Microsoft.Network/routeTables/routes', u'name': u'default', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/routeTables/PwPT-MGMT-APP-RT/routes/default'}], u'subnets': [{u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/virtualNetworks/PwPT-Core-NetMGMT-VNET/subnets/PwPT-MGMT-APP'}], u'resourceGuid': u'af6d05cd-61ad-45c9-8f7d-8418fa58a350', u'disableBgpRoutePropagation': False, u'provisioningState': u'Succeeded'}, u'etag': u'W/"99c971ed-86a1-480e-b0f5-d9069b025cb8"', u'location': u'canadacentral', u'type': u'Microsoft.Network/routeTables', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/routeTables/PwPT-MGMT-APP-RT'}, {u'name': u'PwPT-MGMT-DB-RT', u'tags': {u'Organizations': u'PwP0-CCC-E&O', u'DeploymentVersion': u'2018-12-14-01', u'Classification': u'Unclassified', u'Enviroment': u'Sandbox', u'CostCenter': u'PwP0-EA', u'Owner': u'[email protected]'}, u'properties': {u'routes': [{u'properties': {u'addressPrefix': u'100.96.124.0/24', u'nextHopType': u'VnetLocal', u'provisioningState': u'Succeeded'}, u'etag': u'W/"444e7fd8-0cd9-4dbe-a9df-c8edbdf9943f"', u'type': u'Microsoft.Network/routeTables/routes', u'name': u'local-Subnet', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/routeTables/PwPT-MGMT-DB-RT/routes/local-Subnet'}, {u'properties': {u'addressPrefix': u'100.96.120.0/21', u'nextHopType': u'VirtualAppliance', u'nextHopIpAddress': u'100.96.116.4', u'provisioningState': u'Succeeded'}, u'etag': u'W/"444e7fd8-0cd9-4dbe-a9df-c8edbdf9943f"', u'type': u'Microsoft.Network/routeTables/routes', u'name': u'PwPT-MGMT-VNET', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/routeTables/PwPT-MGMT-DB-RT/routes/PwPT-MGMT-VNET'}, {u'properties': {u'addressPrefix': u'100.96.116.64/27', u'nextHopType': u'VirtualAppliance', u'nextHopIpAddress': u'100.96.116.4', u'provisioningState': u'Succeeded'}, u'etag': u'W/"444e7fd8-0cd9-4dbe-a9df-c8edbdf9943f"', u'type': u'Microsoft.Network/routeTables/routes', u'name': u'PwPT-Management', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/routeTables/PwPT-MGMT-DB-RT/routes/PwPT-Management'}, {u'properties': {u'addressPrefix': u'100.96.112.0/21', u'nextHopType': u'VirtualAppliance', u'nextHopIpAddress': u'100.96.116.4', u'provisioningState': u'Succeeded'}, u'etag': u'W/"444e7fd8-0cd9-4dbe-a9df-c8edbdf9943f"', u'type': u'Microsoft.Network/routeTables/routes', u'name': u'PwPT-Core-VNET', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/routeTables/PwPT-MGMT-DB-RT/routes/PwPT-Core-VNET'}, {u'properties': {u'addressPrefix': u'0.0.0.0/0', u'nextHopType': u'VirtualAppliance', u'nextHopIpAddress': u'100.96.116.4', u'provisioningState': u'Succeeded'}, u'etag': u'W/"444e7fd8-0cd9-4dbe-a9df-c8edbdf9943f"', u'type': u'Microsoft.Network/routeTables/routes', u'name': u'default', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/routeTables/PwPT-MGMT-DB-RT/routes/default'}], u'subnets': [{u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/virtualNetworks/PwPT-Core-NetMGMT-VNET/subnets/PwPT-MGMT-DB'}], u'resourceGuid': u'a4eb6329-5c1c-4714-8d9c-8c8163673ab2', u'disableBgpRoutePropagation': False, u'provisioningState': u'Succeeded'}, u'etag': u'W/"444e7fd8-0cd9-4dbe-a9df-c8edbdf9943f"', u'location': u'canadacentral', u'type': u'Microsoft.Network/routeTables', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/routeTables/PwPT-MGMT-DB-RT'}, {u'name': u'PwPT-MGMT-PAZ-RT', u'tags': {u'Organizations': u'PwP0-CCC-E&O', u'DeploymentVersion': u'2018-12-14-01', u'Classification': u'Unclassified', u'Enviroment': u'Sandbox', u'CostCenter': u'PwP0-EA', u'Owner': u'[email protected]'}, u'properties': {u'routes': [{u'properties': {u'addressPrefix': u'100.96.120.0/24', u'nextHopType': u'VnetLocal', u'provisioningState': u'Succeeded'}, u'etag': u'W/"340298ac-5c42-4482-98e3-f0ac838f4f2d"', u'type': u'Microsoft.Network/routeTables/routes', u'name': u'local-Subnet', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/routeTables/PwPT-MGMT-PAZ-RT/routes/local-Subnet'}, {u'properties': {u'addressPrefix': u'100.96.120.0/21', u'nextHopType': u'VirtualAppliance', u'nextHopIpAddress': u'100.96.116.4', u'provisioningState': u'Succeeded'}, u'etag': u'W/"340298ac-5c42-4482-98e3-f0ac838f4f2d"', u'type': u'Microsoft.Network/routeTables/routes', u'name': u'PwPT-MGMT-VNET', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/routeTables/PwPT-MGMT-PAZ-RT/routes/PwPT-MGMT-VNET'}, {u'properties': {u'addressPrefix': u'100.96.116.64/27', u'nextHopType': u'VirtualAppliance', u'nextHopIpAddress': u'100.96.116.4', u'provisioningState': u'Succeeded'}, u'etag': u'W/"340298ac-5c42-4482-98e3-f0ac838f4f2d"', u'type': u'Microsoft.Network/routeTables/routes', u'name': u'PwPT-Management', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/routeTables/PwPT-MGMT-PAZ-RT/routes/PwPT-Management'}, {u'properties': {u'addressPrefix': u'100.96.112.0/21', u'nextHopType': u'VirtualAppliance', u'nextHopIpAddress': u'100.96.116.4', u'provisioningState': u'Succeeded'}, u'etag': u'W/"340298ac-5c42-4482-98e3-f0ac838f4f2d"', u'type': u'Microsoft.Network/routeTables/routes', u'name': u'PwPT-Core-VNET', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/routeTables/PwPT-MGMT-PAZ-RT/routes/PwPT-Core-VNET'}, {u'properties': {u'addressPrefix': u'0.0.0.0/0', u'nextHopType': u'VirtualAppliance', u'nextHopIpAddress': u'100.96.116.4', u'provisioningState': u'Succeeded'}, u'etag': u'W/"340298ac-5c42-4482-98e3-f0ac838f4f2d"', u'type': u'Microsoft.Network/routeTables/routes', u'name': u'default', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/routeTables/PwPT-MGMT-PAZ-RT/routes/default'}], u'subnets': [{u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/virtualNetworks/PwPT-Core-NetMGMT-VNET/subnets/PwPT-MGMT-PAZ'}], u'resourceGuid': u'3d305560-9c79-4881-b03e-49746eda3de7', u'disableBgpRoutePropagation': False, u'provisioningState': u'Succeeded'}, u'etag': u'W/"340298ac-5c42-4482-98e3-f0ac838f4f2d"', u'location': u'canadacentral', u'type': u'Microsoft.Network/routeTables', u'id': u'/subscriptions/2de839a0-37f9-4163-a32a-e1bdb8d6eb7e/resourceGroups/PwPT-Core-NetMGMT-RG/providers/Microsoft.Network/routeTables/PwPT-MGMT-PAZ-RT'}]
Look like there is only 3 location as expected. Not sure why it is reporting 5 and tripping on those 2 extr.
from py-az2tf.
I appear to have worked around the issue by wrapping the offending code in a try: statement:
try:
name = azr[i]["name"]
loc = azr[i]["location"]
id = azr[i]["id"]
rg = id.split("/")[4].replace(".", "-").lower()
rgs = id.split("/")[4]
except KeyError:
continue
Still report 5 routes but at least it now outputs the actual 3 routes and continue.
from py-az2tf.
That is strange - the REST call is returning only partial information for two of your routes. (the ones without location populated). It shouldn't.
The workaround is good for now while I try and reproduce/figure it out.
from py-az2tf.
Here is a copy of the terraform deployment that is causing the issue on my side. Maybe it will help you reproduce the issue: https://1drv.ms/f/s!AroDHk41Y7i-g8gsl2gmapBj6WGMGw
It was created by weaving together outputs from py-az2tf and making some adjustments to make it use more functions and variables.
from py-az2tf.
that all worked this side - I wonder if you had some routes left over in a partially deleted Resource Group ?
from py-az2tf.
Must be an Azure bug then. Strange that it reports extra empty route-tables entry but I can't see those in the Portal either. Heh. Not the 1st not the last Azure bug.
Or is it possible my docker container is the source? Perhaps some of the version of python resources are causing the issue? If you try to run the same terraform command using the docker image does it also work?
from py-az2tf.
Related Issues (20)
- Invalid escape sequence HOT 3
- Error in az2tf.py Unicode for Policy info HOT 3
- ValueError malformed string in ast.py HOT 5
- Support for other Azure Clouds HOT 3
- Support for Python 3 HOT 1
- Warning: "network_security_group_id": [DEPRECATED] Use the `azurerm_subnet_network_security_group_association` resource instead. HOT 1
- Traffic manager endpoint issue with app service as type HOT 23
- IndexError: list index out of range HOT 7
- Error HOT 17
- Error naming slots resources HOT 1
- The argument "fqdns" was already set at fqdns = ["x.x.x.x"] HOT 2
- Note in resource "azurerm_management_lock" HOT 22
- azurerm_virtual_network_gateway_connection issue HOT 7
- Azure Role Definition Import fails when role definition has no description HOT 1
- terraform validate fails because storage profile block is never created in vmss import HOT 1
- KeyError for loadBalancerBackendAddressPools in vmss HOT 1
- Invalid multi-line string error HOT 4
- Azurerm 2.0 fails to validate HOT 1
- Tool isnt working
- Still active? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from py-az2tf.