You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Read infrastructure data from your cloud and export it to a SQL database.
1
+
# Cloud2SQL 🤩
2
+
Read infrastructure data from your cloud ☁️ and export it to a SQL database 📋.
3
3
4
+

4
5
5
6
## Installation
6
7
7
8
Python 3.9 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
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:
10
+
You can install Cloud2SQL using:
16
11
17
12
```bash
18
-
pip install cloud2sql[all]
13
+
pip install --user cloud2sql[all]
19
14
```
20
15
21
16
If you only require support for a specific database, instead of `cloud2sql[all]` you can choose between `cloud2sql[snowflake]`, `cloud2sql[parquet]`, `cloud2sql[postgresql]`, `cloud2sql[mysql]`.
22
17
23
18
## Usage
24
19
25
20
The sources and destinations for `cloud2sql` are configured via a configuration file. Create your own configuration by adjusting the [config template file](./config-template.yaml).
21
+
26
22
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).
27
23
All sections refer to cloud providers and are enabled if a configuration section is provided.
28
24
29
-
The following databases are currently supported:
25
+
In the next section you will create a YAML configuration file. Once you have created your configuration file, you can run `cloud2sql` with the following command:
26
+
27
+
```bash
28
+
cloud2sql --config myconfig.yaml
29
+
```
30
+
31
+
## Configuration
32
+
33
+
Cloud2SQL uses a YAML configuration file to define the `sources` and `destinations`.
34
+
35
+
### Sources
36
+
37
+
#### AWS
38
+
39
+
```yaml
40
+
sources:
41
+
aws:
42
+
# AWS Access Key ID (null to load from env - recommended)
43
+
access_key_id: null
44
+
# AWS Secret Access Key (null to load from env - recommended)
45
+
secret_access_key: null
46
+
# IAM role name to assume
47
+
role: null
48
+
# List of AWS profiles to collect
49
+
profiles: null
50
+
# List of AWS Regions to collect (null for all)
51
+
region: null
52
+
# Scrape the entire AWS organization
53
+
scrape_org: false
54
+
# Assume given role in current account
55
+
assume_current: false
56
+
# Do not scrape current account
57
+
do_not_scrape_current: false
58
+
```
59
+
60
+
#### Google Cloud
61
+
62
+
```yaml
63
+
sources:
64
+
gcp:
65
+
# GCP service account file(s)
66
+
service_account: []
67
+
# GCP project(s)
68
+
project: []
69
+
```
70
+
71
+
#### Kubernetes
72
+
73
+
```yaml
74
+
sources:
75
+
k8s:
76
+
# Configure access via kubeconfig files.
77
+
# Structure:
78
+
# - path: "/path/to/kubeconfig"
79
+
# all_contexts: false
80
+
# contexts: ["context1", "context2"]
81
+
config_files: []
82
+
# Alternative: configure access to k8s clusters directly in the config.
# DigitalOcean API tokens for the teams to be collected
97
+
api_tokens: []
98
+
# DigitalOcean Spaces access keys for the teams to be collected, separated by colons
99
+
spaces_access_keys: []
100
+
```
101
+
102
+
### Destinations
30
103
31
104
#### SQLite
32
105
33
-
```
106
+
```yaml
34
107
destinations:
35
-
sqlite:
36
-
database: /path/to/database.db
108
+
sqlite:
109
+
database: /path/to/database.db
37
110
```
38
111
39
112
#### PostgreSQL
40
113
41
-
```
114
+
```yaml
42
115
destinations:
43
-
postgresql:
44
-
host: 127.0.0.1
45
-
port: 5432
46
-
user: cloud2sql
47
-
password: changeme
48
-
database: cloud2sql
49
-
args:
50
-
key: value
116
+
postgresql:
117
+
host: 127.0.0.1
118
+
port: 5432
119
+
user: cloud2sql
120
+
password: changeme
121
+
database: cloud2sql
122
+
args:
123
+
key: value
51
124
```
52
125
53
126
#### MySQL
54
127
55
-
```
128
+
```yaml
56
129
destinations:
57
-
mysql:
58
-
host: 127.0.0.1
59
-
port: 3306
60
-
user: cloud2sql
61
-
password: changeme
62
-
database: cloud2sql
63
-
args:
64
-
key: value
130
+
mysql:
131
+
host: 127.0.0.1
132
+
port: 3306
133
+
user: cloud2sql
134
+
password: changeme
135
+
database: cloud2sql
136
+
args:
137
+
key: value
65
138
```
66
139
67
140
#### MariaDB
68
141
69
-
```
142
+
```yaml
70
143
destinations:
71
-
mariadb:
72
-
host: 127.0.0.1
73
-
port: 3306
74
-
user: cloud2sql
75
-
password: changeme
76
-
database: cloud2sql
77
-
args:
78
-
key: value
144
+
mariadb:
145
+
host: 127.0.0.1
146
+
port: 3306
147
+
user: cloud2sql
148
+
password: changeme
149
+
database: cloud2sql
150
+
args:
151
+
key: value
79
152
```
80
153
81
154
#### Snowflake
82
155
83
-
```
156
+
```yaml
84
157
destinations:
85
-
snowflake:
86
-
host: myorg-myaccount
87
-
user: cloud2sql
88
-
password: changeme
89
-
database: cloud2sql/public
90
-
args:
91
-
warehouse: compute_wh
92
-
role: accountadmin
158
+
snowflake:
159
+
host: myorg-myaccount
160
+
user: cloud2sql
161
+
password: changeme
162
+
database: cloud2sql/public
163
+
args:
164
+
warehouse: compute_wh
165
+
role: accountadmin
93
166
```
94
167
95
168
#### Apache Parquet
96
169
97
-
```
170
+
```yaml
98
171
destinations:
99
-
file:
100
-
path: /where/to/write/parquet/files/
101
-
format: parquet
102
-
batch_size: 100_000
172
+
file:
173
+
path: /where/to/write/parquet/files/
174
+
format: parquet
175
+
batch_size: 100_000
103
176
```
104
177
105
178
#### CSV
106
179
107
-
```
180
+
```yaml
108
181
destinations:
109
-
file:
110
-
path: /where/to/write/to/csv/files/
111
-
format: csv
112
-
batch_size: 100_000
182
+
file:
183
+
path: /where/to/write/to/csv/files/
184
+
format: csv
185
+
batch_size: 100_000
113
186
```
114
187
115
188
116
189
#### My database is not listed here
117
190
118
-
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).
191
+
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).
119
192
Install the relevant driver and use the connection string from the documentation.
120
193
121
194
#### Example
@@ -127,6 +200,8 @@ The example uses our AWS default credentials and the default kubernetes config.
127
200
cloud2sql --config config-example.yaml
128
201
```
129
202
203
+
For a more in-depth example, check out our [blog post](https://resoto.com/blog/2022/12/21/installing-cloud2sql).
204
+
130
205
## Local Development
131
206
132
207
Create a local development environment with the following command:
0 commit comments