solarboat 0.8.7

A CLI tool for intelligent Terraform operations management with automatic dependency detection
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
# Solarboat CLI 🚀

[![Release](https://github.com/devqik/solarboat/actions/workflows/release.yml/badge.svg)](https://github.com/devqik/solarboat/actions/workflows/release.yml)
[![Crates.io](https://img.shields.io/crates/v/solarboat)](https://crates.io/crates/solarboat)
[![Website](https://img.shields.io/website?url=https://solarboat.io)](https://solarboat.io)

> Built with love for Rust and infrastructure automation by [Youssef Hussein (@devqik)]https://devqik.com

Solarboat is a modern CLI for Infrastructure as Code (IaC) and GitOps workflows, providing intelligent Terraform operations, automatic dependency detection, and seamless stateful/stateless module handling.

<table>
<tr>
<td width="50%">

## Why "Solarboat"?

Inspired by the Ancient Egyptian solar boats that carried Pharaohs through their celestial journey, this CLI tool is your vessel through the complexities of infrastructure management. Let Solarboat handle the operational journey, so you can focus on writing code.

</td>
<td width="50%">
<img src="./icon.jpg" alt="Solarboat Logo" width="100%">
</td>
</tr>
</table>

---

## ✨ Features

- **Intelligent Terraform Operations**
  - Detects changed modules automatically
  - Handles stateful/stateless modules smartly
  - Propagates dependencies
  - Runs modules in parallel (with safety limits)
  - Detailed, readable reporting
  - Path-based filtering for targeted runs
- **Coming Soon**
  - AI agent
  - Automatic state management
  - Custom workflow automation

---

## 📦 Installation

**With Cargo (Recommended):**

```bash
cargo install solarboat
# Or install a specific version
cargo install solarboat --version 0.8.7
```

**From Release Binaries:**

```bash
curl -L https://github.com/devqik/solarboat/releases/latest/download/solarboat-x86_64-unknown-linux-gnu.tar.gz | tar xz
sudo mv solarboat /usr/local/bin/
```

**From Source:**

```bash
git clone https://github.com/devqik/solarboat.git
cd solarboat
cargo build
```

---

## 🛠️ Usage

### Common Commands

```bash
# Scan for changed Terraform modules
solarboat scan

# Scan a specific directory
solarboat scan --path ./terraform-modules

# Scan with custom default branch
solarboat scan --default-branch develop

# Plan Terraform changes
solarboat plan

# Plan in parallel
solarboat plan --parallel 4

# Save plans to directory
solarboat plan --output-dir ./terraform-plans

# Ignore workspaces
solarboat plan --ignore-workspaces dev,staging

# Plan all stateful modules
solarboat plan --all

# Apply changes (dry-run by default)
solarboat apply

# Apply for real
solarboat apply --dry-run=false

# Ignore workspaces
solarboat apply --ignore-workspaces prod,staging

# Apply all stateful modules
solarboat apply --all

# Real-time output
solarboat plan --watch

# Combine flags
solarboat plan --all --watch --var-files vars.tfvars
```

### Command Overview

- **scan**: Analyze repo for changed modules and dependencies. No changes made.
- **plan**: Generate Terraform plans for changed modules. Supports parallelism, workspace filtering, and output directory.
- **apply**: Apply changes to infrastructure. Dry-run by default, supports real-time output and workspace filtering.

#### Default Branch

- Compares changes against `main` by default. Use `--default-branch` to override.

#### Parallel Processing

- Use `--parallel N` (max 4) to process modules in parallel. Ex: `solarboat plan --parallel 3`
- In `--watch` mode, parallelism is forced to 1 for clean output.

#### Watch Mode

- `--watch` streams real-time Terraform output. Great for debugging and monitoring.
- Without `--watch`, operations run silently for CI/CD cleanliness.

#### Timeout Handling

- Initialization: 5 min
- Planning: 10 min
- Apply: 30 min

---

## ⚙️ Configuration

Solarboat supports flexible configuration via JSON files.

**Quick Start:**

1. Create `solarboat.json` in your project root:

```json
{
  "global": {
    "ignore_workspaces": ["dev", "test"],
    "var_files": ["global.tfvars"],
    "workspace_var_files": {
      "prod": ["prod.tfvars"]
    }
  },
  "modules": {
    "infrastructure/networking": {
      "ignore_workspaces": ["test"],
      "var_files": ["networking.tfvars"],
      "workspace_var_files": {
        "prod": ["networking-prod.tfvars"]
      }
    }
  }
}
```

2. Run Solarboat as usual. It auto-loads your config.

**Environment-Specific Config:**

```bash
SOLARBOAT_ENV=prod solarboat plan
```

Solarboat will look for `solarboat.prod.json` if set.

**Config Precedence:**

1. CLI arguments (highest)
2. Module config
3. Global config
4. Defaults (lowest)

**More:** See [CONFIGURATION.md](./CONFIGURATION.md) for full docs.

---

## 🧑‍💻 GitHub Actions Integration

Solarboat comes with a GitHub Action for CI/CD automation.

### **GitHub Token Requirements**

The GitHub token is **optional** and only needed for:

- 📝 **PR Comments**: Automatic plan summaries posted to pull requests
- 📊 **Enhanced Integration**: Access to GitHub API features

**Most common scenarios:**

- **Basic Usage**: No token required for core functionality (scan, plan, apply)
-**PR Comments**: Use `${{ secrets.GITHUB_TOKEN }}` (automatically provided by GitHub)
- ⚠️ **Custom Permissions**: Use custom token only if default permissions aren't sufficient

### **Basic Workflow (Minimal Setup):**

```yaml
name: Infrastructure CI/CD
on: [push, pull_request]

jobs:
  terraform:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Scan for Changes
        uses: devqik/solarboat@v0.8.7
        with:
          command: scan

      - name: Plan Infrastructure
        if: github.event_name == 'pull_request'
        uses: devqik/solarboat@v0.8.7
        with:
          command: plan
          output-dir: terraform-plans
          # Add token for PR comments
          github_token: ${{ secrets.GITHUB_TOKEN }}

      - name: Apply Changes
        if: github.ref == 'refs/heads/main'
        uses: devqik/solarboat@v0.8.7
        with:
          command: apply
          apply-dryrun: false
```

### **Production Workflow (Full Features):**

```yaml
name: Infrastructure Automation
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

permissions:
  contents: read
  pull-requests: write # For PR comments

jobs:
  infrastructure:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Plan Infrastructure Changes
        if: github.event_name == 'pull_request'
        uses: devqik/solarboat@v0.8.7
        with:
          command: plan
          config: ./infrastructure/solarboat.json
          terraform-version: "1.8.0"
          solarboat-version: "v0.8.7"
          parallel: 3
          ignore-workspaces: dev,test
          output-dir: terraform-plans
          github_token: ${{ secrets.GITHUB_TOKEN }}

      - name: Apply Infrastructure Changes
        if: github.ref == 'refs/heads/main'
        uses: devqik/solarboat@v0.8.7
        with:
          command: apply
          apply-dryrun: false
          config: ./infrastructure/solarboat.json
          terraform-version: "1.8.0"
          parallel: 2
          continue-on-error: false
```

### **Pipeline-Supplied Commits (New Feature)**

Solarboat now supports intelligent change detection with pipeline-supplied commit information for more reliable CI/CD workflows.

#### **Automatic Detection (Recommended)**

The GitHub Action automatically detects the appropriate commits based on the event:

- **Pull Requests**: Uses `base.sha` and `head.sha` from the PR
- **Main Branch Pushes**: Uses `before` and `after` commit hashes
- **Local Mode**: Falls back to checking recent commits (configurable)

#### **Manual Commit Specification**

For advanced use cases, you can manually specify commit ranges:

```yaml
- name: Custom Commit Comparison
  uses: devqik/solarboat@v0.8.7
  with:
    command: plan
    base-commit: abc1234
    head-commit: def5678
    base-branch: main
    head-branch: feature/new-module
```

#### **Local Development Mode**

When no commit information is provided, Solarboat runs in local mode:

```yaml
- name: Local Development Mode
  uses: devqik/solarboat@v0.8.7
  with:
    command: plan
    recent-commits: 5 # Check last 5 commits for changes
```

### **Action Inputs:**

| Input               | Description                              | Default           | Required |
| ------------------- | ---------------------------------------- | ----------------- | -------- |
| `command`           | Command to run (`scan`, `plan`, `apply`) | -                 ||
| `github_token`      | GitHub token for PR comments             | -                 ||
| `config`            | Path to Solarboat configuration file     | auto-detect       ||
| `output-dir`        | Directory for plan files                 | `terraform-plans` ||
| `apply-dryrun`      | Run apply in dry-run mode                | `true`            ||
| `ignore-workspaces` | Comma-separated workspaces to ignore     | -                 ||
| `var-files`         | Comma-separated var files to use         | -                 ||
| `path`              | Directory to scan for modules            | `.`               ||
| `all`               | Process all stateful modules             | `false`           ||
| `watch`             | Show real-time output                    | `false`           ||
| `parallel`          | Number of parallel processes (max 4)     | `1`               ||
| `default-branch`    | Default git branch for comparisons       | `main`            ||
| `recent-commits`    | Recent commits to check (local mode)     | `5`               ||
| `base-commit`       | Base commit SHA for comparison           | auto-detect       ||
| `head-commit`       | Head commit SHA for comparison           | auto-detect       ||
| `base-branch`       | Base branch name for comparison          | auto-detect       ||
| `head-branch`       | Head branch name for comparison          | auto-detect       ||
| `solarboat-version` | Solarboat CLI version to use             | `latest`          ||
| `terraform-version` | Terraform version to use                 | `latest`          ||
| `continue-on-error` | Continue workflow on Solarboat failure   | `false`           ||

### **Action Outputs:**

| Output            | Description                             |
| ----------------- | --------------------------------------- |
| `result`          | Command result (`success` or `failure`) |
| `plans-path`      | Path to generated Terraform plans       |
| `changed-modules` | Number of changed modules detected      |

### **Advanced Examples:**

**Conditional workflows based on outputs:**

```yaml
- name: Plan Infrastructure
  id: plan
  uses: devqik/solarboat@v0.8.7
  with:
    command: plan
    github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Notify on Changes
  if: steps.plan.outputs.changed-modules != '0'
  run: |
    echo "🚨 ${{ steps.plan.outputs.changed-modules }} modules changed!"
    echo "Plans available at: ${{ steps.plan.outputs.plans-path }}"
```

**Multi-environment with configuration:**

```yaml
- name: Plan Staging
  uses: devqik/solarboat@v0.8.7
  with:
    command: plan
    config: ./configs/solarboat.staging.json
    path: ./environments/staging

- name: Plan Production
  uses: devqik/solarboat@v0.8.7
  with:
    command: plan
    config: ./configs/solarboat.prod.json
    path: ./environments/production
    ignore-workspaces: dev,staging,test
```

**Error handling:**

```yaml
- name: Apply with Error Handling
  uses: devqik/solarboat@v0.8.7
  with:
    command: apply
    apply-dryrun: false
    continue-on-error: true

- name: Handle Failures
  if: failure()
  run: |
    echo "🚨 Infrastructure apply failed!"
    echo "Check logs and retry manually"
```

### **Permissions**

For PR comments, ensure your workflow has the correct permissions:

```yaml
permissions:
  contents: read # Read repository contents
  pull-requests: write # Comment on pull requests
```

**Note**: `${{ secrets.GITHUB_TOKEN }}` is automatically provided by GitHub with repository access. Custom tokens are only needed for cross-repository access or enhanced permissions.

---

## Contributing 🤝

Contributions are welcome! Please feel free to submit a Pull Request.

## License 📄

This project is licensed under the BSD-3-Clause License - see the [LICENSE](LICENSE) file for details.

## Support 💬

- Issues: [GitHub Issues]https://github.com/devqik/solarboat/issues
- Discussions: [GitHub Discussions]https://github.com/devqik/solarboat/discussions
- Documentation: [Wiki]https://github.com/devqik/solarboat/wiki

## Acknowledgments 🙏

This project needs your support! If you find Solarboat CLI useful, please consider:

- ⭐ Starring the project on GitHub
- 🛠️ Contributing with code, documentation, or bug reports
- 💡 Suggesting new features or improvements
- 🌟 Sharing it with other developers

Your support will help make this project better and encourage its continued development.

~ [Youssef Hussein (@devqik](https://devqik.com) (Creator)