{"id":18906506,"url":"https://github.com/claranet/aws-inventory-graph","last_synced_at":"2025-04-15T04:31:37.413Z","repository":{"id":49687864,"uuid":"225454701","full_name":"claranet/aws-inventory-graph","owner":"claranet","description":"Explore your AWS platform with, Dgraph, a graph database.","archived":false,"fork":false,"pushed_at":"2020-01-02T09:36:16.000Z","size":288,"stargazers_count":65,"open_issues_count":1,"forks_count":10,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-28T00:34:31.596Z","etag":null,"topics":["aws","dgraph","golang","graphdb","inventory"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/claranet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"securitygroups.go","support":null}},"created_at":"2019-12-02T19:42:00.000Z","updated_at":"2025-03-08T18:22:24.000Z","dependencies_parsed_at":"2022-09-19T09:50:45.660Z","dependency_job_id":null,"html_url":"https://github.com/claranet/aws-inventory-graph","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claranet%2Faws-inventory-graph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claranet%2Faws-inventory-graph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claranet%2Faws-inventory-graph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claranet%2Faws-inventory-graph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/claranet","download_url":"https://codeload.github.com/claranet/aws-inventory-graph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249006447,"owners_count":21197279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","dgraph","golang","graphdb","inventory"],"created_at":"2024-11-08T09:16:32.645Z","updated_at":"2025-04-15T04:31:36.904Z","avatar_url":"https://github.com/claranet.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Description\r\n\r\n![release](https://flat.badgen.net/github/release/claranet/aws-inventory-graph/latest?color=green) ![last commit](https://flat.badgen.net/github/last-commit/claranet/aws-inventory-graph) ![licence](https://flat.badgen.net/github/license/claranet/aws-inventory-graph) ![stars](https://flat.badgen.net/github/stars/claranet/aws-inventory-graph)\r\n\r\nExplore your AWS platform with, [`Dgraph`](https://dgraph.io/), a graph database.\r\n\r\n![screenshot](./img/screenshot.png)\r\n\r\nThanks to Go and its goroutines, we can insert thousand of ressources in few seconds.\r\n\r\n## Prerequisites\r\n\r\n- [docker](https://docs.docker.com/)\r\n- [docker-compose](https://docs.docker.com/compose/install/)\r\n- [Go](https://golang.org/) (for build only)\r\n\r\n## Install\r\n\r\nDownload and move to `/usr/local/bin/` a binary from [release page](https://github.com/claranet/aws-inventory-graph/releases)\r\n\r\n## Build\r\n\r\nThis project uses *go.mod*, so after cloning this repo, simply run :\r\n\r\n```bash\r\ngo build \u0026\u0026 chmod +x ./aws-inventory-graph\r\n```\r\n\r\nor\r\n\r\n```bash\r\nGOBIN=/usr/local/bin/ go install \u0026\u0026 chmod +x /usr/local/bin/aws-inventory-graph\r\n```\r\n\r\n## Usage\r\n\r\n### Start Dgraph server\r\n\r\n```bash\r\nmake\r\n```\r\n\r\nor\r\n\r\n```bash\r\nmake up\r\n```\r\n\r\nAccess to WebUI (**dgraph-ratel**) : [http://localhost:8000](http://localhost:8000)\r\n\r\n### Import ressources\r\n\r\nAuthentication is based on your `.aws/config` file.\r\n\r\n```bash\r\nUsage of aws-inventory-graph:\r\n  -dgraph string\r\n        Dgraph server (ip:port) (default \"127.0.0.1:9080\")\r\n  -drop\r\n        Drop all nodes and the schema\r\n  -list\r\n        List available ressource types\r\n  -no-schema\r\n        Disable the refresh schema at each run\r\n  -profile string\r\n        Profile from ~/.aws/config (default \"default\")\r\n  -region string\r\n        AWS Region (default \"eu-west-1\")\r\n  -type string\r\n        Get the schema for a type (only after importing some data)\r\n```\r\n\r\nExample :\r\n\r\n```bash\r\naws-inventory-graph -region us-west-2 -profile xxxx\r\n\r\n2019/11/29 17:35:58 Drop all previous data\r\n2019/11/29 17:35:58 Add schema\r\n2019/11/29 17:36:04 List ...\r\n...\r\n2019/11/29 17:36:05 Add ... Nodes\r\n...\r\n2019/11/29 17:36:08 Add ... Edges\r\n...\r\n```\r\n\r\n### Get schema for a type\r\n\r\nYou can get all schemas for *types* and *predicates* in **dgraph-ratel** WebUI:\r\n\r\n![schemas](./img/schemas.png)\r\n\r\nor with binary, in JSON format :\r\n\r\n```bash\r\naws-inventory-graph -type Address | jq\r\n\r\n{\r\n  \"types\": [\r\n    {\r\n      \"fields\": [\r\n        {\r\n          \"name\": \"name\",\r\n          \"type\": \"string\"\r\n        },\r\n        {\r\n          \"name\": \"Service\",\r\n          \"type\": \"string\"\r\n        },\r\n        {\r\n          \"name\": \"Region\",\r\n          \"type\": \"string\"\r\n        },\r\n        {\r\n          \"name\": \"OwnerId\",\r\n          \"type\": \"string\"\r\n        },\r\n        {\r\n          \"name\": \"PrivateIpAddress\",\r\n          \"type\": \"string\"\r\n        },\r\n        {\r\n          \"name\": \"PublicIp\",\r\n          \"type\": \"string\"\r\n        },\r\n        {\r\n          \"name\": \"Domain\",\r\n          \"type\": \"string\"\r\n        },\r\n        {\r\n          \"name\": \"AllocationId\",\r\n          \"type\": \"string\"\r\n        },\r\n        {\r\n          \"name\": \"_Instance\",\r\n          \"type\": \"Instance\"\r\n        }\r\n      ],\r\n      \"name\": \"Address\"\r\n    }\r\n  ]\r\n}\r\n```\r\n\r\n**Predicates which are prefixed with a `_` are Edges, and they all have a reverse.**\r\n\r\n## Stop and/or Remove Dgraph\r\n\r\nStop :\r\n\r\n```bash\r\nmake stop\r\n```\r\n\r\nRemove :\r\n\r\n```bash\r\nmake rm\r\n```\r\n\r\n## Available Ressources\r\n\r\nHere the list of currently supported ressources :\r\n\r\n- Address\r\n- AutoScalingGroup\r\n- AvailabilityZone\r\n- CacheCluster\r\n- CacheSubnetGroup\r\n- Cidr\r\n- DbCluster\r\n- DbClusterParameterGroup\r\n- DbInstance\r\n- DbParameterGroup\r\n- DbSubnetGroup\r\n- Image\r\n- Instance\r\n- InstanceProfile\r\n- KeyPair\r\n- LaunchConfiguration\r\n- LaunchTemplate\r\n- LoadBalancer\r\n- NatGateway\r\n- OptionGroup\r\n- SecurityGroup\r\n- Snapshot\r\n- Subnet\r\n- TargetGroup\r\n- Volume\r\n- Vpc\r\n- VpcPeeringConnection\r\n\r\n**All Edges between the Nodes have reversed.**\r\n\r\n:warning: AWS API is often messy, names are not consistent from one endpoint to another, we try to fix that and keep a global coherance. This is why some Predicates don't match exact names returned by API.\r\n\r\n## Query examples\r\n\r\nSee [here](https://docs.dgraph.io/query-language/) to get more info about **Dgraph’s GraphQL+**.\r\n\r\n### Get Elastic IPs + Instances + NatGateways\r\n\r\n```bash\r\n{\r\n  Address(func: type(Address)) @filter(has(_Instance) or has(_NatGateway)){\r\n    name dgraph.type PublicIp\r\n    Instance:_Instance {name dgraph.type InstanceId}\r\n    NatGateway: _NatGateway{name dgraph.type NatGatewayID}\r\n  }\r\n}\r\n```\r\n\r\n### Get Classic LoadBalancers + AutoScalingGroups + Instances\r\n\r\n```bash\r\n{\r\n  LoadBalancer(func: type(LoadBalancer))@filter(eq(LoadBalancerType, classic)) @cascade{\r\n    name dgraph.type\r\n    AutoScaling:~_LoadBalancer {\r\n        name dgraph.type\r\n        Instance:_Instance{\r\n            name dgraph.type InstanceId\r\n        }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### Get Application LoadBalancers + TargetGroups + AutoScalingGroups + Instances\r\n\r\n```bash\r\n{\r\n  LoadBalancerV2(func: type(LoadBalancer))@filter(eq(LoadBalancerType, application))@cascade{\r\n    name dgraph.type\r\n    TargetGroup:~_LoadBalancer @filter(type(TargetGroup)){\r\n        name dgraph.type\r\n        AutoScalingGroup:~_TargetGroup @filter(type(AutoScalingGroup)){\r\n            name dgraph.type Instance:_Instance{\r\n                name dgraph.type InstanceId\r\n            }\r\n        }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### Get VpcPeeringConnections + Vpcs\r\n\r\n```bash\r\n{\r\n  VpcPeeringConnection(func: type(VpcPeeringConnection)){\r\n    name dgraph.type VpcPeeringConnectionId\r\n    AccepterVpc:_AccepterVpc {name dgraph.type VpcId}\r\n    RequesterVpc:_RequesterVpc {name dgraph.type VpcId}\r\n  }\r\n}\r\n```\r\n\r\n### Get which Instances have access to which DbInstances\r\n\r\n```bash\r\n{\r\n  DbInstances(func: type(DbInstance))@cascade{\r\n    name dgraph.type\r\n    SecurityGroup:_SecurityGroup {\r\n      name dgraph.type GroupId\r\n      IngressSecurityGroup:_SecurityGroup @facets {\r\n        name dgraph.type\r\n        Instance:~_SecurityGroup @filter(type(Instance)){\r\n          name dgraph.type InstanceId\r\n        }\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### Get the Cidr which are allowed for access to DbInstances\r\n\r\n```bash\r\n{\r\n  Rds(func: type(DbInstance))@cascade{\r\n    name dgraph.type\r\n    SecurityGroup:_SecurityGroup {\r\n      name dgraph.type GroupId\r\n      IngressCidr:_Cidr @facets {\r\n        name dgraph.type\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### Get Instance opened worldwide + associated ports\r\n\r\n```bash\r\n{\r\n  OpenWorldCidr(func: eq(name, \"0.0.0.0/0\"))@cascade{\r\n    name dgraph.type\r\n    SecurityGroup:~_Cidr @filter(type(SecurityGroup)) @facets {\r\n      name dgraph.type GroupId\r\n      Instance:~_SecurityGroup @filter(type(Instance)){\r\n        name dgraph.type InstanceId\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### Get which KeyPairs give access to which Instances\r\n\r\n```bash\r\n{\r\n  KeyPair(func: type(KeyPair))@cascade{\r\n    name dgraph.type\r\n    Instance:~_KeyName{\r\n      name dgraph.type InstanceId\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### Get CacheClusters (Elasticache) with Instances which have access to them\r\n\r\n```bash\r\n{\r\n  Memcached(func: type(CacheCluster))@filter(eq(Engine, memcached))@cascade{\r\n    name dgraph.type\r\n    SecurityGroup:_SecurityGroup @facets {\r\n      name dgraph.type\r\n      IngressSecurityGroup:_SecurityGroup @facets {\r\n        name dgraph.type\r\n        Instance:~_SecurityGroup @filter(type(Instance)){\r\n          name dgraph.type InstanceId\r\n        }\r\n      }\r\n    }\r\n  }\r\n  Redis(func: type(CacheCluster))@filter(eq(Engine, redis))@cascade{\r\n    name dgraph.type\r\n    SecurityGroup:_SecurityGroup @facets {\r\n      name dgraph.type\r\n      IngressSecurityGroup:_SecurityGroup @facets {\r\n        name dgraph.type\r\n        Instance:~_SecurityGroup @filter(type(Instance)){\r\n          name dgraph.type InstanceId\r\n        }\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### Get InstanceProfiles which are not used by Instances\r\n\r\n```bash\r\n{\r\n  InstanceProfile(func: type(InstanceProfile)) @filter(not has(~_InstanceProfile)) {\r\n    name dgraph.type\r\n  }\r\n}\r\n```\r\n\r\n### Get Instances without backup (no linked Snapshot)\r\n\r\n```bash\r\n{\r\n  Instance(func: type(Instance)) @filter(eq(OwnerName, univadis-prod)) @cascade{\r\n    name dgraph.type\r\n    Volume:~_Instance @filter(not has(~_Volume) and type(Volume)){}\r\n  }\r\n}\r\n```\r\n\r\n### Get the sum of Volumes by type\r\n\r\n```bash\r\n{\r\n  var(func: type(Volume))  @filter(eq(VolumeType, gp2)){\r\n    A as Size\r\n  }\r\n  var(func: type(Volume))  @filter(eq(VolumeType, standard)){\r\n    B as Size\r\n  }\r\n  Volume(){\r\n    gp2:sum(val(A))\r\n    standard:sum(val(B))\r\n  }\r\n}\r\n```\r\n\r\n## Author\r\n\r\nThomas Labarussias ([@Issif](https://github.com/Issif))\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclaranet%2Faws-inventory-graph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclaranet%2Faws-inventory-graph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclaranet%2Faws-inventory-graph/lists"}