Getting Started
stackql-deploy is a model driven, declarative framework for provisioning, de-provisioning and testing cloud resources. Heard enough and ready to get started? Jump to a Quick Start.
Installing stackql-deploy
stackql-deploy is distributed as a standalone binary with no runtime dependencies required.
- macOS
- Linux
- Windows
- Cargo (from source)
- GitHub Actions
Apple Silicon (ARM64):
curl -L https://github.com/stackql/stackql-deploy-rs/releases/latest/download/stackql-deploy-macos-arm64.tar.gz | tar xz
sudo mv stackql-deploy /usr/local/bin/
Intel (x86_64):
curl -L https://github.com/stackql/stackql-deploy-rs/releases/latest/download/stackql-deploy-macos-x86_64.tar.gz | tar xz
sudo mv stackql-deploy /usr/local/bin/
x86_64:
curl -L https://github.com/stackql/stackql-deploy-rs/releases/latest/download/stackql-deploy-linux-x86_64.tar.gz | tar xz
sudo mv stackql-deploy /usr/local/bin/
ARM64:
curl -L https://github.com/stackql/stackql-deploy-rs/releases/latest/download/stackql-deploy-linux-arm64.tar.gz | tar xz
sudo mv stackql-deploy /usr/local/bin/
PowerShell:
Invoke-WebRequest -Uri "https://github.com/stackql/stackql-deploy-rs/releases/latest/download/stackql-deploy-windows-x86_64.zip" -OutFile stackql-deploy.zip
Expand-Archive stackql-deploy.zip -DestinationPath .
Move-Item stackql-deploy.exe "$env:LOCALAPPDATA\Microsoft\WindowsApps\"
Remove-Item stackql-deploy.zip
WSL / Git Bash:
curl -L -o stackql-deploy.zip https://github.com/stackql/stackql-deploy-rs/releases/latest/download/stackql-deploy-windows-x86_64.zip
unzip stackql-deploy.zip
If you have Rust installed (via rustup):
cargo install stackql-deploy
This builds from source and installs to ~/.cargo/bin/.
Use the stackql/setup-deploy action to install and run stackql-deploy in your CI/CD pipelines:
steps:
- uses: actions/checkout@v4
- name: Deploy Stack
uses: stackql/setup-deploy@v1.0.1
with:
command: 'build'
stack_dir: 'examples/aws/aws-vpc-webserver'
stack_env: 'dev'
env_vars: 'AWS_REGION=us-east-1'
The action automatically downloads the latest binary for the runner's platform. See Deploying with GitHub Actions for the full reference.
All platform binaries are available on the GitHub Releases page.
How stackql-deploy works
The core components of stackql-deploy are the stack directory, the stackql_manifest.yml file and resource query (.iql) files. These files define your infrastructure and guide the deployment process.
stackql-deploy uses the stackql_manifest.yml file in the stack-dir, to render query templates (.iql files) in the resources sub directory of the stack-dir, targeting an environment (stack-env). stackql is used to execute the queries to deploy, test, update or delete resources as directed. This is summarized in the diagram below:
stackql_manifest.yml File
The stackql_manifest.yml file is the basis of your stack configuration. It contains the definitions of the resources you want to manage, the providers you're using (such as AWS, Google Cloud, or Azure), and the environment-specific settings that will guide the deployment.
This manifest file acts as a blueprint for your infrastructure, describing the resources and how they should be configured. An example stackql_manifest.yml file is shown here:
version: 1
name: "my-azure-stack"
description: description for "my-azure-stack"
providers:
- azure
globals:
- name: subscription_id
description: azure subscription id
value: "{{ AZURE_SUBSCRIPTION_ID }}"
- name: location
description: default location for resources
value: eastus
- name: global_tags
value:
provisioner: stackql
stackName: "{{ stack_name }}"
stackEnv: "{{ stack_env }}"
resources:
- name: example_res_grp
props:
- name: resource_group_name
value: "{{ stack_name }}-{{ stack_env }}-rg"
exports:
- resource_group_name
The stackql_manifest.yml file is detailed here.
Resource Query Files
Each resource or query defined in the resources section of the stackql_manifest.yml has an associated StackQL query file (using the .iql extension by convention). The query file defines queries to deploy and test a cloud resource. These queries are demarcated by query anchors (or hints). Available query anchors include:
exists: tests for the existence or non-existence of a resourcecreate: creates the resource in the desired state using a StackQLINSERTstatementupdate: updates the resource to the desired state using a StackQLUPDATEstatementcreateorupdate: for idempotent resources, uses a StackQLINSERTstatementstatecheck: tests the state of a resource after a DML operation, typically to determine if the resource is in the desired stateexports: variables to export from the resource to be used in subsequent queriesdelete: deletes a resource using a StackQLDELETEstatement
An example resource query file is shown here:
/*+ exists */
SELECT COUNT(*) as count FROM azure.resources.resource_groups
WHERE subscriptionId = '{{ subscription_id }}'
AND resourceGroupName = '{{ resource_group_name }}'
/*+ create */
INSERT INTO azure.resources.resource_groups(
resourceGroupName,
subscriptionId,
location
)
SELECT
'{{ resource_group_name }}',
'{{ subscription_id }}',
'{{ location }}'
/*+ statecheck, retries=5, retry_delay=5 */
SELECT COUNT(*) as count FROM azure.resources.resource_groups
WHERE subscriptionId = '{{ subscription_id }}'
AND resourceGroupName = '{{ resource_group_name }}'
AND location = '{{ location }}'
AND JSON_EXTRACT(properties, '$.provisioningState') = 'Succeeded'
/*+ exports */
SELECT '{{ resource_group_name }}' as resource_group_name
/*+ delete */
DELETE FROM azure.resources.resource_groups
WHERE resourceGroupName = '{{ resource_group_name }}' AND subscriptionId = '{{ subscription_id }}'
Resource queries are detailed here.
stackql-deploy commands
Basic stackql-deploy commands include:
build: provisions a stack to the desired state in a specified environment (includingcreateandupdateoperations if necessary)test: tests a stack to confirm all resources exist and are in their desired stateteardown: de-provisions a stack
here are some examples:
stackql-deploy build my-azure-stack prd \
-e AZURE_SUBSCRIPTION_ID=00000000-0000-0000-0000-000000000000
stackql-deploy test my-azure-stack sit \
-e AZURE_SUBSCRIPTION_ID=00000000-0000-0000-0000-000000000000
stackql-deploy teardown my-azure-stack dev \
-e AZURE_SUBSCRIPTION_ID=00000000-0000-0000-0000-000000000000
For more detailed information see cli-reference/build, cli-reference/test, cli-reference/teardown, or other commands available.
stackql-deploy deployment flow
stackql-deploy processes the resources defined in the stackql_manifest.yml in top down order (teardown operations are processed in reverse order).
Quick Start
To get up and running quickly, stackql-deploy provides a set of quick start templates for common cloud providers. These templates include predefined configurations and resource queries tailored to AWS, Azure, and Google Cloud, among others.
- AWS Quick Start Template: A basic setup for deploying a VPC, including subnets and routing configurations.
- Azure Quick Start Template: A setup for creating a Resource Group with associated resources.
- Google Cloud Quick Start Template: A configuration for deploying a VPC with network and firewall rules.
These templates are designed to help you kickstart your infrastructure deployment with minimal effort, providing a solid foundation that you can customize to meet your specific needs.