-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ingest GCP folders, projects, and instances (#71)
* Add GCP folders (no cleanup yet) * Add GCP projects * Add GCP instances * Add indices * Add cleanup jobs for GCP folders, projects, and instances. Separate compute module to own python file. * Fix flake8 problems * Update schema docs with GCP Projects, Folders, and Instances * Doc update and remove extra space * Refactor so that we only get projects once and provide that data to all dependent modules * Add docs on gcp/__init__.py * Improve googleapi error handling * Add docs to compute.py functions * Replace :PARENT relationship with :RESOURCE to be consistent with AWS. Separate GCP schema docs from AWS schema docs. * Fix linter errors * Fix exception handling with getting project zones * Space * Add docs for compute.py * Add generic :Instance label to EC2Instances and GCPInstances * Explicitly handle being unable to enum projects, folders, and organizations. MERGE organizations rather than MATCH them when ingesting projects to avoid crash when a project has an organization that we do not know about as a parent. * Handle projects that do not have parents. Update schema docs to the correct links. * avoid link rot * Reraise exceptions unless we can actually handle them * Fix exception handling, add debug and info messages before syncs, add generic sync function for compute.py * Catch specific exception instead of base one
- Loading branch information
Showing
14 changed files
with
722 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
cartography/data/jobs/cleanup/gcp_compute_instance_cleanup.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"statements": [ | ||
{ | ||
"query": "MATCH (n:GCPInstance) WHERE n.lastupdated <> {UPDATE_TAG} WITH n LIMIT {LIMIT_SIZE} DETACH DELETE (n) return COUNT(*) as TotalCompleted", | ||
"iterative": true, | ||
"iterationsize": 100, | ||
"__comment__": "Delete GCP Instances that no longer exist and detach them from all previously connected nodes." | ||
}, | ||
{ | ||
"query": "MATCH (:GCPInstance)<-[r:RESOURCE]-(:GCPProject) WHERE r.lastupdated <> {UPDATE_TAG} WITH r LIMIT {LIMIT_SIZE} DELETE (r) return COUNT(*) as TotalCompleted", | ||
"iterative": true, | ||
"iterationsize": 100, | ||
"__comment__": "Remove GCP Instance-to-Project relationships that are out of date." | ||
} | ||
], | ||
"name": "cleanup GCP Instances" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"statements": [ | ||
{ | ||
"query": "MATCH (n:GCPFolder) WHERE n.lastupdated <> {UPDATE_TAG} WITH n LIMIT {LIMIT_SIZE} DETACH DELETE (n) return COUNT(*) as TotalCompleted", | ||
"iterative": true, | ||
"iterationsize": 100, | ||
"__comment__": "Delete GCPFolders that no longer exist and detach them from all previously connected nodes" | ||
}, | ||
{ | ||
"query": "MATCH (:GCPFolder)-[r:RESOURCE]-(:GCPFolder) WHERE r.lastupdated <> {UPDATE_TAG} WITH distinct r LIMIT {LIMIT_SIZE} DELETE (r) return COUNT(*) as TotalCompleted", | ||
"iterative": true, | ||
"iterationsize": 100, | ||
"__comment__": "Remove GCP Folder-to-Folder relationships that are out of date." | ||
}, | ||
{ | ||
"query": "MATCH (:GCPFolder)<-[r:RESOURCE]-(:GCPOrganization) WHERE r.lastupdated <> {UPDATE_TAG} WITH r LIMIT {LIMIT_SIZE} DELETE (r) return COUNT(*) as TotalCompleted", | ||
"iterative": true, | ||
"iterationsize": 100, | ||
"__comment__": "Remove GCP Folder-to-Organization relationships that are out of date." | ||
} | ||
], | ||
"name": "cleanup GCP Folders" | ||
} |
17 changes: 17 additions & 0 deletions
17
cartography/data/jobs/cleanup/gcp_crm_organization_cleanup.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"statements": [ | ||
{ | ||
"query": "MATCH (n:GCPOrganization) WHERE n.lastupdated <> {UPDATE_TAG} WITH n LIMIT {LIMIT_SIZE} DETACH DELETE (n) return COUNT(*) as TotalCompleted", | ||
"iterative": true, | ||
"iterationsize": 100, | ||
"__comment__": "Remove GCP organizations that are out of date." | ||
}, | ||
{ | ||
"query": "MATCH (:GCPOrganization)-[r:RESOURCE]->(:GCPProject) WHERE r.lastupdated <> {UPDATE_TAG} WITH r LIMIT {LIMIT_SIZE} DELETE (r) return COUNT(*) as TotalCompleted", | ||
"iterative": true, | ||
"iterationsize": 100, | ||
"__comment__": "Remove GCP Organization relationships that are out of date." | ||
} | ||
], | ||
"name": "cleanup GCP Organizations" | ||
} |
23 changes: 23 additions & 0 deletions
23
cartography/data/jobs/cleanup/gcp_crm_project_cleanup.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"statements": [ | ||
{ | ||
"query": "MATCH (n:GCPProject) WHERE n.lastupdated <> {UPDATE_TAG} WITH n LIMIT {LIMIT_SIZE} DETACH DELETE (n) return COUNT(*) as TotalCompleted", | ||
"iterative": true, | ||
"iterationsize": 100, | ||
"__comment__": "Delete GCP Projects that no longer exist and detach them from all previously connected nodes." | ||
}, | ||
{ | ||
"query": "MATCH (:GCPProject)<-[r:RESOURCE]-(:GCPFolder) WHERE r.lastupdated <> {UPDATE_TAG} WITH r LIMIT {LIMIT_SIZE} DELETE (r) return COUNT(*) as TotalCompleted", | ||
"iterative": true, | ||
"iterationsize": 100, | ||
"__comment__": "Remove GCP Project-to-Folder relationships that are out of date." | ||
}, | ||
{ | ||
"query": "MATCH (:GCPProject)<-[r:RESOURCE]-(:GCPOrganization) WHERE r.lastupdated <> {UPDATE_TAG} WITH r LIMIT {LIMIT_SIZE} DELETE (r) return COUNT(*) as TotalCompleted", | ||
"iterative": true, | ||
"iterationsize": 100, | ||
"__comment__": "Remove GCP Project-to-Organization relationships that are out of date." | ||
} | ||
], | ||
"name": "cleanup GCP Projects" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.