|
1 | | -# stackql-deploy |
| 1 | +<div align="center"> |
2 | 2 |
|
3 | | -[](https://crates.io/crates/stackql-deploy) |
4 | | -[](https://opensource.org/licenses/MIT) |
| 3 | +[](https://github.com/stackql/stackql) |
5 | 4 |
|
6 | | -**stackql-deploy** is an infrastructure-as-code framework for declarative cloud resource management using [StackQL](https://stackql.io). Define your cloud resources once using StackQL queries and YAML manifests, then `build`, `test`, and `teardown` across any environment. |
| 5 | +**Model-driven resource provisioning and deployment framework using StackQL.** |
7 | 6 |
|
8 | | -> This is the Rust rewrite (v2.x). The original Python package (`stackql-deploy` on PyPI, v1.x) is archived — see the [Python package changelog](https://github.com/stackql/stackql-deploy/blob/main/CHANGELOG.md) for prior release history. |
| 7 | +[](https://crates.io/crates/stackql-deploy) |
| 8 | +[](https://crates.io/crates/stackql-deploy) |
| 9 | +[](LICENSE) |
| 10 | +[](https://github.com/stackql/stackql-deploy/releases) |
| 11 | +[](https://stackql-deploy.io/docs) |
9 | 12 |
|
10 | | ---- |
11 | | - |
12 | | -## Install |
| 13 | +</div> |
13 | 14 |
|
14 | | -### Via `cargo` |
15 | | - |
16 | | -```sh |
17 | | -cargo install stackql-deploy |
18 | | -``` |
| 15 | +--- |
19 | 16 |
|
20 | | -### Direct binary download |
| 17 | +**stackql-deploy** is a multi-cloud Infrastructure-as-Code framework inspired by [dbt](https://www.getdbt.com/), built on top of [StackQL](https://github.com/stackql/stackql). Define cloud resources as SQL-like models, then `build`, `test`, and `teardown` across any environment — no state files required. |
21 | 18 |
|
22 | | -Pre-built binaries for Linux (x86_64 / ARM64), macOS (Apple Silicon / Intel), and Windows (x86_64) are available on the [GitHub Releases](https://github.com/stackql/stackql-deploy/releases) page. |
| 19 | +> This is the Rust rewrite (v2.x). The original Python package (v1.x, last release 1.9.4) is now archived — see its [changelog](https://github.com/stackql/stackql-deploy/blob/main/CHANGELOG.md) for prior history. |
23 | 20 |
|
24 | | -**Linux / macOS:** |
| 21 | +## Install |
25 | 22 |
|
| 23 | +**Via `cargo`:** |
26 | 24 | ```sh |
27 | | -# Replace <version> and <target> as appropriate, e.g. 2.0.0 and linux-x86_64 |
28 | | -curl -L https://github.com/stackql/stackql-deploy/releases/download/v<version>/stackql-deploy-<target>.tar.gz | tar xz |
29 | | -chmod +x stackql-deploy |
30 | | -sudo mv stackql-deploy /usr/local/bin/ |
| 25 | +cargo install stackql-deploy |
31 | 26 | ``` |
32 | 27 |
|
33 | | -**Windows:** |
34 | | - |
35 | | -Download the `.zip` from the releases page and add the extracted binary to your `PATH`. |
36 | | - |
37 | | ---- |
| 28 | +**Direct binary download** (Linux, macOS, Windows — x86\_64 and ARM64): |
38 | 29 |
|
39 | | -## Quick start |
| 30 | +Download the latest release from the [GitHub Releases](https://github.com/stackql/stackql-deploy/releases) page, extract, and place the binary on your `PATH`. |
40 | 31 |
|
41 | | -### 1. Initialise a new project |
| 32 | +## How it works |
42 | 33 |
|
43 | | -```sh |
44 | | -# Using a built-in provider template |
45 | | -stackql-deploy init my-stack --provider aws |
| 34 | +A `stackql-deploy` project is a directory with a manifest and StackQL query files: |
46 | 35 |
|
47 | | -# Using a template from the template hub |
48 | | -stackql-deploy init my-stack --template google/starter |
49 | 36 | ``` |
50 | | - |
51 | | -### 2. Build (deploy) your stack |
52 | | - |
53 | | -```sh |
54 | | -stackql-deploy build my-stack dev |
| 37 | +example_stack/ |
| 38 | +├── stackql_manifest.yml |
| 39 | +└── resources/ |
| 40 | + └── monitor_resource_group.iql |
55 | 41 | ``` |
56 | 42 |
|
57 | | -### 3. Test your stack |
58 | | - |
59 | | -```sh |
60 | | -stackql-deploy test my-stack dev |
| 43 | +The manifest declares providers, global variables, and resources: |
| 44 | + |
| 45 | +```yaml |
| 46 | +version: 1 |
| 47 | +name: example_stack |
| 48 | +description: activity monitor stack |
| 49 | +providers: |
| 50 | + - azure |
| 51 | +globals: |
| 52 | + - name: subscription_id |
| 53 | + value: "{{ vars.AZURE_SUBSCRIPTION_ID }}" |
| 54 | + - name: location |
| 55 | + value: eastus |
| 56 | +resources: |
| 57 | + - name: monitor_resource_group |
| 58 | + description: azure resource group |
| 59 | + props: |
| 60 | + - name: resource_group_name |
| 61 | + value: "activity-monitor-{{ globals.stack_env }}" |
61 | 62 | ``` |
62 | 63 |
|
63 | | -### 4. Tear down your stack |
| 64 | +> Use `stackql-deploy init example_stack --provider azure` to scaffold a new project. |
| 65 | + |
| 66 | +Resource `.iql` files define mutation and check queries using SQL anchors: |
| 67 | + |
| 68 | +```sql |
| 69 | +/*+ create */ |
| 70 | +INSERT INTO azure.resources.resource_groups( |
| 71 | + resourceGroupName, subscriptionId, data__location |
| 72 | +) |
| 73 | +SELECT '{{ resource_group_name }}', '{{ subscription_id }}', '{{ location }}' |
| 74 | +
|
| 75 | +/*+ update */ |
| 76 | +UPDATE azure.resources.resource_groups |
| 77 | +SET data__location = '{{ location }}' |
| 78 | +WHERE resourceGroupName = '{{ resource_group_name }}' |
| 79 | + AND subscriptionId = '{{ subscription_id }}' |
| 80 | +
|
| 81 | +/*+ delete */ |
| 82 | +DELETE FROM azure.resources.resource_groups |
| 83 | +WHERE resourceGroupName = '{{ resource_group_name }}' |
| 84 | + AND subscriptionId = '{{ subscription_id }}' |
| 85 | +
|
| 86 | +/*+ exists */ |
| 87 | +SELECT COUNT(*) as count FROM azure.resources.resource_groups |
| 88 | +WHERE subscriptionId = '{{ subscription_id }}' |
| 89 | + AND resourceGroupName = '{{ resource_group_name }}' |
| 90 | +
|
| 91 | +/*+ statecheck, retries=5, retry_delay=5 */ |
| 92 | +SELECT COUNT(*) as count FROM azure.resources.resource_groups |
| 93 | +WHERE subscriptionId = '{{ subscription_id }}' |
| 94 | + AND resourceGroupName = '{{ resource_group_name }}' |
| 95 | + AND location = '{{ location }}' |
| 96 | + AND JSON_EXTRACT(properties, '$.provisioningState') = 'Succeeded' |
| 97 | +
|
| 98 | +/*+ exports */ |
| 99 | +SELECT resourceGroupName, location |
| 100 | +FROM azure.resources.resource_groups |
| 101 | +WHERE subscriptionId = '{{ subscription_id }}' |
| 102 | + AND resourceGroupName = '{{ resource_group_name }}' |
| 103 | +``` |
64 | 104 |
|
65 | | -```sh |
66 | | -stackql-deploy teardown my-stack dev |
| 105 | +### Query execution strategy |
| 106 | + |
| 107 | +For each resource, `stackql-deploy` selects an execution path based on which anchors are defined in the `.iql` file: |
| 108 | + |
| 109 | +```mermaid |
| 110 | +graph TB |
| 111 | + A[resource] --> B{has\ncreateorupdate?} |
| 112 | + B -- Yes --> C[run createorupdate\nskip all checks] |
| 113 | + B -- No --> D{has statecheck?} |
| 114 | +
|
| 115 | + D -- Yes --> E[exists check] |
| 116 | + E --> F{exists?} |
| 117 | + F -- No --> G[create] |
| 118 | + F -- Yes --> H[statecheck] |
| 119 | + H --> I{correct\nstate?} |
| 120 | + I -- Yes --> J[✅ up to date] |
| 121 | + I -- No --> K[update] |
| 122 | + G & K --> L[post-deploy exports] |
| 123 | +
|
| 124 | + D -- No --> M{has exports?} |
| 125 | + M -- Yes --> N[⚡ try exports first] |
| 126 | + N --> O{returned\ndata?} |
| 127 | + O -- Yes --> P[✅ validated +\nexports captured\nin 1 query] |
| 128 | + O -- No --> Q[exists check] |
| 129 | + Q --> R{exists?} |
| 130 | + R -- No --> S[create] |
| 131 | + R -- Yes --> S2[update] |
| 132 | + S & S2 --> T[exports] |
| 133 | + M -- No --> U[exists check\ncreate or update] |
67 | 134 | ``` |
68 | 135 |
|
69 | | -### Other commands |
| 136 | +**Tip:** when there is no `statecheck`, an `exports` query that selects from the live resource serves as both a validation and data-extraction step in a single API call. |
| 137 | + |
| 138 | +## Usage |
70 | 139 |
|
71 | 140 | ```sh |
72 | | -# Show version / provider info |
73 | | -stackql-deploy info |
| 141 | +# Preview what would change (no mutations) |
| 142 | +stackql-deploy build example_stack dev --dry-run |
74 | 143 |
|
75 | | -# Interactive StackQL shell |
76 | | -stackql-deploy shell |
| 144 | +# Deploy |
| 145 | +stackql-deploy build example_stack dev -e AZURE_SUBSCRIPTION_ID=00000000-0000-0000-0000-000000000000 |
77 | 146 |
|
78 | | -# Update the embedded StackQL binary |
79 | | -stackql-deploy upgrade |
| 147 | +# Run checks only |
| 148 | +stackql-deploy test example_stack dev |
80 | 149 |
|
81 | | -# Preview what build would do (no changes applied) |
82 | | -stackql-deploy build my-stack dev --dry-run |
| 150 | +# Deprovision (reverse order) |
| 151 | +stackql-deploy teardown example_stack dev |
83 | 152 | ``` |
84 | 153 |
|
85 | | ---- |
| 154 | +Common flags: |
86 | 155 |
|
87 | | -## Project structure |
| 156 | +| Flag | Description | |
| 157 | +|---|---| |
| 158 | +| `--dry-run` | Print queries, make no changes | |
| 159 | +| `--on-failure=rollback` | `rollback`, `ignore`, or `error` (default) | |
| 160 | +| `--env-file=.env` | Load environment variables from a file | |
| 161 | +| `-e KEY=value` | Pass individual environment variables | |
| 162 | +| `--log-level` | `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL` | |
| 163 | +| `--show-queries` | Print rendered SQL before execution | |
88 | 164 |
|
89 | | -A `stackql-deploy` project consists of a manifest file and one or more StackQL query files: |
| 165 | +Show environment and provider info: |
90 | 166 |
|
| 167 | +```sh |
| 168 | +stackql-deploy info |
91 | 169 | ``` |
92 | | -my-stack/ |
93 | | -├── stackql_manifest.yml # Declares resources, providers, and environment config |
94 | | -└── resources/ |
95 | | - └── my_bucket.iql # StackQL queries for create/exists/state checks |
96 | | -``` |
97 | | - |
98 | | -See the [documentation site](https://stackql.io/docs/stackql-deploy) for the full manifest reference and query file format. |
99 | 170 |
|
100 | | ---- |
| 171 | +Full command reference: |
101 | 172 |
|
102 | | -## Supported providers |
| 173 | +```sh |
| 174 | +stackql-deploy --help |
| 175 | +``` |
103 | 176 |
|
104 | | -stackql-deploy works with any provider supported by StackQL, including AWS, Google Cloud, Azure, Databricks, Snowflake, and more. See [registry.stackql.io](https://registry.stackql.io) for the full provider list. |
| 177 | +## Documentation |
105 | 178 |
|
106 | | ---- |
| 179 | +Full documentation — manifest reference, query anchors, template filters, provider examples — is at **[stackql-deploy.io/docs](https://stackql-deploy.io/docs)**. |
107 | 180 |
|
108 | 181 | ## License |
109 | 182 |
|
110 | | -MIT — see [LICENSE](LICENSE) for details. |
| 183 | +MIT — see [LICENSE](LICENSE). |
0 commit comments