professional-services: SyntaxError in gcpviz
I was trying to run gcpviz example from the documents:
docker run --rm -v $PWD/cai:/gcpviz/cai IMAGE_ID gcpviz.sh network --query-file queries/data.js
And getting the following error:
Failed to create graph: SyntaxError: (anonymous): Line 103:16 Unexpected token ILLEGAL (and 2 more errors)
To reproduce:
gcloud asset export --content-type=resource --output-path="gs://PATH" --project=PROJECT
# Download result to folder name cai
cd tools/gcpviz
docker build .
docker run --rm -v $PWD/cai:/gcpviz/cai IMAGE_ID gcpviz.sh network --query-file queries/data.js
Docker version:Docker version 19.03.13, build 4484c46d9d
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 15 (1 by maintainers)
Yes, that did the trick, thanks, I only now saw the glcoud example in README. Now the “dot” command runs for two hours, no sure if it’s normal. IMO the issue could be closed, but I’m not the OP.
Just add
--content-type resourceto thegcloud asset exportcommand and you should get the resource objects 😃I think the message has to do with that you don’t have an organization resource in your
resource_inventory.json. Have you done an export of the entire organization? You can check if you have the organization resource by running:If you don’t have it, you probably have exported only one project (
gcloud asset exportwith--projectflag). Try to export the entire organization by specifying the--organizationflag togcloud asset export.If you want to visualize 1 project only, you could change the
queries/data.json line 103 from:to
You can also see the
queries/one-project-example.json how to pass the project ID via command line.Have same problem. Basically it fails on this step:
./gcpviz -mode visualize --query-file queries/data.js > cai/network.gvSame docker image builded locally.