Comments (20)
Good find - I'll get that into all of the code this weekend ....
from az2tf.
the -s is expecting a subscription id - you can't use a subscription name
the az2th.sh - runs this command to get a list of subscriptions:
az account list --query '[].id' | jq '.[]' | tr -d '"'
Try running this command above - it should return a list of subscription id's
one of which should be a86bc126-XXXX-XXXX-XXXX-7e546be7a509
Is this so ?
from az2tf.
Wow, thanks for getting back to me so quickly!
➜ az2tf git:(master) az account list --query '[].id' | jq '.[]' | tr -d '"'
parse error: Invalid numeric literal at line 2, column 4
However if I do:
➜ az2tf git:(master) az account list --query '[].id'
[
"10963f71-XXXX-XXXX-XXXX-76109759447c",
"464daa41-XXXX-XXXX-XXXX-5bb3ab855efb",
"a86bc126-XXXX-XXXX-XXXX-7e546be7a509"
]
and then
➜ az2tf git:(master) az account list --query '[].id' | jq '.[]'
parse error: Invalid numeric literal at line 2, column 4
So it would seem that something is up with jq not parsing the list correctly?
I'm running the latest version:
➜ az2tf git:(master) jq --version
jq-1.6
Any ideas on what else I could check?
from az2tf.
Which Operating System are you using ?
Upgraded to jq 1.6 on my macOS - but it still works ok here.....
from az2tf.
macOS Mojave 10.14.2 (18C54)
from az2tf.
me too ... this is odd.
az version ?
from az2tf.
Ok now here's something even weirder: if I copy the text and manually pipe it through echo, it works fine:
➜ az2tf git:(master) echo '["10963f71-XXXX-XXXX-XXXX-76109759447c","464daa41-XXXX-XXXX-XXXX-5bb3ab855efb","a86bc126-XXXX-XXXX-XXXX-7e546be7a509"]' | jq '.[]'
"10963f71-XXXX-XXXX-XXXX-76109759447c"
"464daa41-XXXX-XXXX-XXXX-5bb3ab855efb"
"a86bc126-XXXX-XXXX-XXXX-7e546be7a509"
➜ az2tf git:(master) az -v
azure-cli (2.0.52)
from az2tf.
For posterity's sake, I upgraded azure-cli to 2.0.54 but am still having the same problem. I've also opened a case on the jq GitHub repo (jqlang/jq#1787) in case this is something they can shed some light on.
from az2tf.
we could replace the line in az2tf.sh with:
az account list --query '[].id' | cut -f2 -d '"' | grep "-"
My concern would be that your jq issues will cause other problems as this tool uses jq everywhere !
from az2tf.
So yeah that definitely allowed it to proceed past the original failure point but it wasn't able to find any resource groups, etc. I think I'll wait to hear back from the jq team about what could be wrong.
from az2tf.
I installed jq with brew - did you ?
from az2tf.
Yeah, and I just tried uninstalling and reinstalling it, and the same thing happened.
¯\_(ツ)_/¯
from az2tf.
Ok so I figured out the problem: for some reason azure-cli is inserting ANSI color codes in the output before it's piped to jq. (Possibly because I'm using oh_my_zsh instead of the standard BASH shell?)
The solution is to add the option: -o json
to each call of az like this:
az account list --query '[].id' -o json | jq '.[]' | tr -d '"'
which tells azure-cli to print to stdout without the color codes. I've tried adding to various combinations that you've got in your script but I still haven't figured out which ones need it and which don't. I'll keep working on it if I can find some time this week, but if you are able to check too, that would be a great help.
from az2tf.
Thank you so much!
from az2tf.
found some time - uploaded all the changes - let me know how you get on ?
from az2tf.
Oh wow, it got WAY farther this time. It generated a bunch of .tf files (PROGRESS!) but it eventually spit out this error:
Terraform Plan ...
Error: Error asking for user input: Error parsing address 'azurerm_resource_group': invalid resource address "azurerm_resource_group"
Is that a me-problem?
from az2tf.
If you didn’t - delete the tf.xxxxx-xxxx-xxxx-xxxxxx directory before you run az2tf.sh
That error looks like there may be a malformed .tf file hanging around from a previous run
from az2tf.
So it looks like it works beautifully (haven't found any problems) except this error is thrown near the beginning but the whole script continues and seems to work fine otherwise?
az lock list: error: argument --query: invalid jmespath_type value: '[].resourceGroup -o json'
Not sure if that's important or not?
from az2tf.
typo in az2tf.sh causing that - just posted fix. You only need to run again if you are using locks and want them terraform'ed.
from az2tf.
Love it!
I know we use Logic Apps, Function Apps, Data Lakes and Data Factories here pretty heavily so I'll work on adding them as scripts and will submit PRs in the next few weeks if you're OK with that? I'm leaving for holidays tomorrow so I won't have much time in the next week or two, but I'll do what I can.
Thank you again for such an awesome tool!
from az2tf.
Related Issues (15)
- Partial mode? HOT 2
- BuiltInRole types HOT 3
- Several pull requests HOT 1
- Parsing port range with "-" causes scripts to fail HOT 2
- application_gateway capacity null HOT 1
- Resources 0 of 0 HOT 2
- No dots allowed in resource group or resource names. Throws errors in Terraform!? HOT 5
- error while running script on Mac HOT 1
- Issues with importing resource tags HOT 5
- Function App HOT 2
- Autoscaling HOT 2
- Password handled incorrectly for azurerm_sql_server
- Missing License HOT 4
- Script adds user directory to resource's ID 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 az2tf.