Using cloudgragh in projects

Manthan Ankolekar - Nov 22 '22 - - Dev Community

CloudGraph is the free open-source universal GraphQL API and Cloud Security Posture Management (CSPM) tool for AWS, Azure, GCP, and K8s.

Installation :

System Requirements : Docker

Homebrew :

brew install cloudgraphdev/tap/cg
Enter fullscreen mode Exit fullscreen mode

NPM :

npm i -g @cloudgraph/cli
Enter fullscreen mode Exit fullscreen mode

Adding providers :

cg init aws
cg init azure
cg init gcp
cg init k8s
cg init tencent
Enter fullscreen mode Exit fullscreen mode

Run :

cg init
Enter fullscreen mode Exit fullscreen mode
cg launch
Enter fullscreen mode Exit fullscreen mode

Docker must be running else use these commands :

docker run -it -p 8995:5080 -p 8996:6080 -p 8997:8080 -p 8998:9080 -p 8999:8000
  --label cloudgraph-cli-dgraph-standalone -v ~/dgraph:/dgraph --name dgraph dgraph/standalone:v21.03.1
Enter fullscreen mode Exit fullscreen mode
cg scan
Enter fullscreen mode Exit fullscreen mode

Next playground will open.

Stop Instance

cg teardown
Enter fullscreen mode Exit fullscreen mode

To remove the container after stopping it, run :

cg teardown --delete-image
Enter fullscreen mode Exit fullscreen mode

*Loading Previous Versions*

cg load
Enter fullscreen mode Exit fullscreen mode

Basic Query Syntax Examples:

query {
  getawsEc2(
    arn: "arn:aws:ec2:us-east-1:123445678997:instance/i-12345567889012234"
  ) {
    id
    arn
  }
}
Enter fullscreen mode Exit fullscreen mode

This will return

{
  "data": {
    "getawsEc2": {
      "id": "i-12345567889012234",
      "arn": "arn:aws:ec2:us-east-1:123445678997:instance/i-12345567889012234"
    }
  },
  "extensions": {
    "touched_uids": 4
  }
}
Enter fullscreen mode Exit fullscreen mode

For more info visit :

https://github.com/cloudgraphdev/cli

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .