Skip to content

Commit 8def361

Browse files
authored
feat: Add Readme and configuration (#3)
* feat: Add Readme and configuration * improve readme
1 parent 4aa32c9 commit 8def361

File tree

8 files changed

+198
-21
lines changed

8 files changed

+198
-21
lines changed

Makefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,6 @@ coverage: ## check code coverage quickly with the default Python
7676
venv:
7777
python3 -m venv venv --prompt "cloud2sql"
7878
. ./venv/bin/activate && python3 -m pip install --upgrade pip
79-
# region as long as version 3 is not available on pypi
80-
. ./venv/bin/activate && pip install -e ../resoto/resotolib
81-
. ./venv/bin/activate && pip install -e ../resoto/plugins/aws
82-
. ./venv/bin/activate && pip install -e ../resoto/plugins/digitalocean
83-
. ./venv/bin/activate && pip install -e ../resoto/plugins/gcp
84-
. ./venv/bin/activate && pip install -e ../resoto/plugins/k8s
85-
. ./venv/bin/activate && pip install -e ../resoto/plugins/example_collector
86-
# end region
8779
. ./venv/bin/activate && pip install -r requirements-test.txt
8880
. ./venv/bin/activate && pip install -r requirements.txt
8981
. ./venv/bin/activate && pip install -e .

README.md

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,76 @@
11
# cloud2sql
2-
Read infrastructure data from your cloud and export it to an SQL database.
2+
Read infrastructure data from your cloud and export it to a SQL database.
3+
4+
5+
## Installation
6+
7+
Python 3.10 or higher is required.
8+
It is recommended to use a separate virtual environment for this project. You can create one with the following command:
9+
10+
```bash
11+
python3 -m venv venv --prompt "cloud2sql"
12+
source venv/bin/activate
13+
```
14+
15+
Once the virtual environment is activated, you can install cloud2sql:
16+
17+
```bash
18+
pip install cloud2sql
19+
```
20+
21+
## Usage
22+
23+
The sources for `cloud2sql` are configured via a configuration file. Create your own configuration by adjusting the [config template file](./config-template.yaml).
24+
You can safely delete the sections that are not relevant to you (e.g. if you do not use AWS, you can delete the `aws` section).
25+
All sections refer to cloud providers and are enabled if a configuration section is provided.
26+
27+
After the sources are configured, you need to define the url to the database.
28+
The following databases are currently supported:
29+
30+
#### SQLite
31+
32+
```
33+
sqlite:///path/to/resoto.db
34+
```
35+
36+
#### PostgreSQL
37+
38+
```
39+
postgresql://user:password@host:port/dbname[?key=value&key=value...]
40+
```
41+
42+
#### MySQL
43+
44+
```
45+
mysql://username:password@host/dbname[?key=value&key=value...]
46+
```
47+
48+
#### MariaDB
49+
50+
```
51+
mariadb://username:password@host/dbname[?key=value&key=value...]
52+
```
53+
54+
#### My database is not listed here
55+
56+
cloud2sql uses SQLAlchemy to connect to the database. If your database is not listed here, you can check if it is supported in [SQLAlchemy Dialects](https://docs.sqlalchemy.org/en/20/dialects/index.html).
57+
Install the relevant driver and use the connection string from the documentation.
58+
59+
#### Example
60+
61+
We use a minimal configuration [example](./config-example.yaml) and export the data to a SQLite database.
62+
The example uses our AWS default credentials and the default kubernetes config.
63+
64+
```bash
65+
cloud2sql --config config-example.yaml --db "sqlite:///resoto.db"
66+
```
67+
68+
## Local Development
69+
70+
Create a local development environment with the following command:
71+
72+
```bash
73+
make setup
74+
source venv/bin/activate
75+
```
76+

cloud2sql/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
"""
22
Cloud2Sql
33
~~~~~~~~~~~~~~~~~~~~~~~~~~
4-
Read infrastructure data from your cloud and export it to an SQL database.
4+
Read infrastructure data from your cloud and export it to a SQL database.
55
:copyright: © 2022 Some Engineering Inc.
66
:license: Apache 2.0, see LICENSE for more details.
77
"""
88

99
__title__ = "cloud2sql"
10-
__description__ = "Read infrastructure data from your cloud and export it to an SQL database."
10+
__description__ = "Read infrastructure data from your cloud and export it to a SQL database."
1111
__author__ = "Some Engineering Inc."
1212
__license__ = "Apache 2.0"
1313
__copyright__ = "Copyright © 2022 Some Engineering Inc."
14+
__version__ = "0.4.0"

config-example.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
aws:
2+
# Take the aws default profile in ~/.aws/credentials and collect 2 regions
3+
region: ["us-east-1", "eu-central-1"]
4+
k8s:
5+
# Use the default kubeconfig file and collect all contexts.
6+
config_files:
7+
- path: "~/.kube/config"
8+
all_contexts: true

config-template.yaml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
aws:
2+
# AWS Access Key ID (null to load from env - recommended)
3+
access_key_id: null
4+
# AWS Secret Access Key (null to load from env - recommended)
5+
secret_access_key: null
6+
# IAM role name to assume
7+
role: null
8+
# List of AWS profiles to collect
9+
profiles: null
10+
# List of AWS Account ID(s) to collect (null for all if scrape_org is true)
11+
account: null
12+
# List of AWS Regions to collect (null for all)
13+
region: null
14+
# Scrape the entire AWS organization
15+
scrape_org: false
16+
# Fork collector process instead of using threads
17+
fork_process: true
18+
# List of accounts to exclude when scraping the org
19+
scrape_exclude_account: []
20+
# Assume given role in current account
21+
assume_current: false
22+
# Do not scrape current account
23+
do_not_scrape_current: false
24+
# Account thread/process pool size
25+
account_pool_size: 8
26+
# Region thread pool size
27+
region_pool_size: 128
28+
# Number of threads available shared for all regions
29+
shared_pool_size: 128
30+
# Number of threads to collect a single region
31+
region_resources_pool_size: 2
32+
# List of AWS services to collect (default: all)
33+
collect: []
34+
# List of AWS services to exclude (default: none)
35+
no_collect: []
36+
# This value is used to look up atime and mtime for volumes and rds instances.
37+
# It defines how long Resoto should look back for CloudWatch metrics.
38+
# If no metric is found, now-period is used as atime and mtime. Defaults to 60 days.
39+
cloudwatch_metrics_for_atime_mtime_period: '60d'
40+
# Granularity of atime and mtime.
41+
# Higher precision is more expensive: Resoto will fetch period * granularity data points.
42+
# Defaults to 1 hour.
43+
cloudwatch_metrics_for_atime_mtime_granularity: '1h'
44+
gcp:
45+
# GCP service account file(s)
46+
service_account: []
47+
# GCP project(s)
48+
project: []
49+
# GCP services to collect (default: all)
50+
collect: []
51+
# GCP services to exclude (default: none)
52+
no_collect: []
53+
# GCP project thread/process pool size
54+
project_pool_size: 8
55+
# Fork collector process instead of using threads
56+
fork_process: true
57+
digitalocean:
58+
# DigitalOcean API tokens for the teams to be collected
59+
api_tokens: []
60+
# DigitalOcean Spaces access keys for the teams to be collected, separated by colons
61+
spaces_access_keys: []
62+
k8s:
63+
# Configure access via kubeconfig files.
64+
# Structure:
65+
# - path: "/path/to/kubeconfig"
66+
# all_contexts: false
67+
# contexts: ["context1", "context2"]
68+
config_files: []
69+
# Alternative: configure access to k8s clusters directly in the config.
70+
# Structure:
71+
# - name: 'k8s-cluster-name'
72+
# certificate_authority_data: 'CERT'
73+
# server: 'https://k8s-cluster-server.example.com'
74+
# token: 'TOKEN'
75+
configs: []
76+
# Objects to collect (default: all)
77+
collect: []
78+
# Objects to exclude (default: none)
79+
no_collect: []
80+
# Thread/process pool size
81+
pool_size: 8
82+
# Fork collector process instead of using threads
83+
fork_process: false
84+
slack:
85+
# Bot token
86+
bot_token: null
87+
# Include archived channels
88+
include_archived: false
89+
# Do not verify the Slack API server TLS certificate
90+
do_not_verify_ssl: false
91+
onelogin:
92+
# Onelogin region
93+
region: 'us'
94+
# Onelogin client ID
95+
client_id: null
96+
# Onelogin client secret
97+
client_secret: null

requirements-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ mypy==0.982
66
tox==3.27.1
77
wheel==0.38.4
88
coverage==6.5.0
9+
resoto-plugin-example-collector==3.0.0rc3

requirements.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44
SQLAlchemy==2.0.0b3
55
PyYAML==6.0
66
rich==12.6.0
7-
resotolib==3.0.0a0
87
resotoclient==1.2.1
98

109
# bundle popular db drivers
11-
psycopg2==2.9.5 # postgres
10+
psycopg2-binary==2.9.5 # postgres
1211
pymysql==1.0.2 # mysql + mariadb
1312

13+
resotolib==3.0.0rc3
1414
# all collector plugins
15-
resoto-plugin-aws==3.0.0a0
16-
resoto-plugin-digitalocean==3.0.0a0
17-
resoto-plugin-gcp==3.0.0a0
18-
resoto-plugin-k8s==3.0.0a0
15+
resoto-plugin-aws==3.0.0rc3
16+
resoto-plugin-digitalocean==3.0.0rc3
17+
resoto-plugin-gcp==3.0.0rc3
18+
resoto-plugin-k8s==3.0.0rc3
19+
resoto-plugin-slack==3.0.0rc3
20+
resoto-plugin-onelogin==3.0.0rc3
1921

setup.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from setuptools import setup, find_packages
66

7+
import cloud2sql
8+
79
with open("requirements.txt") as f:
810
required = f.read().splitlines()
911

@@ -19,10 +21,10 @@
1921

2022

2123
setup(
22-
name="cloud2sql",
23-
version="1.0.0a1",
24-
description="Read infrastructure data from your cloud and export it to an SQL database.",
25-
python_requires=">=3.9",
24+
name=cloud2sql.__title__,
25+
version=cloud2sql.__version__,
26+
description=cloud2sql.__description__,
27+
python_requires=">=3.10",
2628
classifiers=["Programming Language :: Python :: 3"],
2729
entry_points={"console_scripts": ["cloud2sql=cloud2sql.__main__:main"]},
2830
install_requires=required,

0 commit comments

Comments
 (0)