Introducing the GitHub CloudQuery Plugin
CloudQuery is an open-source, extensible framework that gives you a single-pane-of-glass to your cloud-infrastructure using SQL. Today, we are happy to announce the release of the GitHub Provider for CloudQuery.
Ron Eliahu • Aug 08, 2022
CloudQuery is an open-source, extendable framework that gives you a single-pane-of-glass to your cloud-infrastructure using SQL. Today, we are happy to announce the release of the GitHub Provider for CloudQuery.
GitHub is a source-control provider that helps developers store and manage their code, as well as track and control changes to their code.
In this tutorial, we will install CloudQuery and use it to fetch GitHub resources. Then, we will use SQL to get visibility into security, compliance and cost-management in GitHub.
- Acquire a GitHub (personal access token)[https://email@example.com/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token] with the scopes:
read:org read:project public_repo ```.
- Create a
cloudquery.ymlfile, similar to the following:
kind: source spec: name: github path: cloudquery/github registry: cloudquery version: 'VERSION_SOURCE_GITHUB' tables: ['*'] destinations: ['postgresql'] spec: access_token: <YOUR_ACCESS_TOKEN> orgs: ['cloudquery'] --- kind: destination spec: name: 'postgresql' path: cloudquery/postgresql registry: cloudquery version: 'VERSION_DESTINATION_POSTGRESQL' write_mode: 'overwrite-delete-stale' spec: connection_string: 'postgresql://postgres:pass@localhost:5432/postgres?sslmode=disable'
cloudquery sync cloudquery.yml
After we finish fetching our config data we can make queries for security, compliance, cost management and other purposes.
-- Query all repositories in the organizations that are public SELECT id, org, name, description FROM github_repositories WHERE private = false
-- Get billing information state for actions, packages and storage SELECT * FROM github_billing_action SELECT * FROM github_billing_package SELECT * FROM github_billing_storage
-- Find all open issues that have been open for more than 7 days SELECT gr.org, gr.name, gi.id, gi.state, gi.created_at, gi.updated_at FROM github_issues gi INNER JOIN github_repositories gr ON gr.id = (gi.repository->'id')::bigint WHERE state = 'open' AND NOW() - interval '7 days' > gi.created_at