diff --git a/.github/workflows/stackql-deploy-actions-test.yml b/.github/workflows/stackql-deploy-actions-test.yml index ee12c0a..fed988f 100644 --- a/.github/workflows/stackql-deploy-actions-test.yml +++ b/.github/workflows/stackql-deploy-actions-test.yml @@ -1,31 +1,304 @@ -name: Test StackQL Deploy Action +name: StackQL Deploy Action Test (AWS SSM) on: push: branches: - main + +# Run tests sequentially to avoid race conditions on shared AWS resources. +# Order: Linux amd64 → Linux arm64 → macOS arm → macOS Intel → Windows + jobs: - stackql-actions-test: - name: StackQL Actions Test + test-ubuntu-latest: + name: "Test (ubuntu-latest)" runs-on: ubuntu-latest env: - GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} - + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }} steps: - - name: Checkout - uses: actions/checkout@v4.1.7 + - uses: actions/checkout@v6 + - name: Deploy SSM Parameter + uses: ./ + with: + command: 'build' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Test SSM Parameter + uses: ./ + with: + command: 'test' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Update Manifest - Update SSM Parameter Value + shell: bash + run: | + sed -i.bak 's/stackql-deploy-action-test-value/stackql-deploy-action-test-value-updated/' examples/aws-ssm-parameter/stackql_manifest.yml + rm -f examples/aws-ssm-parameter/stackql_manifest.yml.bak + echo "Updated manifest:" + cat examples/aws-ssm-parameter/stackql_manifest.yml + - name: Redeploy SSM Parameter with Updated Value + uses: ./ + with: + command: 'build' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Test SSM Parameter (Post-Update) + uses: ./ + with: + command: 'test' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Teardown SSM Parameter + if: always() + uses: ./ + with: + command: 'teardown' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' - - name: StackQL Deploy Info + test-ubuntu-arm: + name: "Test (ubuntu-24.04-arm)" + needs: test-ubuntu-latest + runs-on: ubuntu-24.04-arm + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }} + steps: + - uses: actions/checkout@v6 + - name: Deploy SSM Parameter + uses: ./ + with: + command: 'build' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Test SSM Parameter + uses: ./ + with: + command: 'test' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Update Manifest - Update SSM Parameter Value + shell: bash + run: | + sed -i.bak 's/stackql-deploy-action-test-value/stackql-deploy-action-test-value-updated/' examples/aws-ssm-parameter/stackql_manifest.yml + rm -f examples/aws-ssm-parameter/stackql_manifest.yml.bak + echo "Updated manifest:" + cat examples/aws-ssm-parameter/stackql_manifest.yml + - name: Redeploy SSM Parameter with Updated Value + uses: ./ + with: + command: 'build' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Test SSM Parameter (Post-Update) + uses: ./ + with: + command: 'test' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Teardown SSM Parameter + if: always() uses: ./ with: - command: 'info' + command: 'teardown' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' - - name: Run StackQL Deploy Action + test-macos-arm: + name: "Test (macos-latest)" + needs: test-ubuntu-arm + runs-on: macos-latest + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }} + steps: + - uses: actions/checkout@v6 + - name: Deploy SSM Parameter + uses: ./ + with: + command: 'build' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Test SSM Parameter uses: ./ with: command: 'test' - stack_dir: 'examples/k8s-the-hard-way' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Update Manifest - Update SSM Parameter Value + shell: bash + run: | + sed -i.bak 's/stackql-deploy-action-test-value/stackql-deploy-action-test-value-updated/' examples/aws-ssm-parameter/stackql_manifest.yml + rm -f examples/aws-ssm-parameter/stackql_manifest.yml.bak + echo "Updated manifest:" + cat examples/aws-ssm-parameter/stackql_manifest.yml + - name: Redeploy SSM Parameter with Updated Value + uses: ./ + with: + command: 'build' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Test SSM Parameter (Post-Update) + uses: ./ + with: + command: 'test' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Teardown SSM Parameter + if: always() + uses: ./ + with: + command: 'teardown' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + + test-macos-intel: + name: "Test (macos-26-intel)" + needs: test-macos-arm + runs-on: macos-26-intel + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }} + steps: + - uses: actions/checkout@v6 + - name: Deploy SSM Parameter + uses: ./ + with: + command: 'build' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Test SSM Parameter + uses: ./ + with: + command: 'test' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Update Manifest - Update SSM Parameter Value + shell: bash + run: | + sed -i.bak 's/stackql-deploy-action-test-value/stackql-deploy-action-test-value-updated/' examples/aws-ssm-parameter/stackql_manifest.yml + rm -f examples/aws-ssm-parameter/stackql_manifest.yml.bak + echo "Updated manifest:" + cat examples/aws-ssm-parameter/stackql_manifest.yml + - name: Redeploy SSM Parameter with Updated Value + uses: ./ + with: + command: 'build' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Test SSM Parameter (Post-Update) + uses: ./ + with: + command: 'test' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Teardown SSM Parameter + if: always() + uses: ./ + with: + command: 'teardown' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + + test-windows: + name: "Test (windows-latest)" + needs: test-macos-intel + runs-on: windows-latest + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }} + steps: + - uses: actions/checkout@v6 + - name: Deploy SSM Parameter + uses: ./ + with: + command: 'build' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Test SSM Parameter + uses: ./ + with: + command: 'test' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Update Manifest - Update SSM Parameter Value + shell: bash + run: | + sed -i.bak 's/stackql-deploy-action-test-value/stackql-deploy-action-test-value-updated/' examples/aws-ssm-parameter/stackql_manifest.yml + rm -f examples/aws-ssm-parameter/stackql_manifest.yml.bak + echo "Updated manifest:" + cat examples/aws-ssm-parameter/stackql_manifest.yml + - name: Redeploy SSM Parameter with Updated Value + uses: ./ + with: + command: 'build' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Test SSM Parameter (Post-Update) + uses: ./ + with: + command: 'test' + stack_dir: 'examples/aws-ssm-parameter' + stack_env: 'dev' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' + - name: Teardown SSM Parameter + if: always() + uses: ./ + with: + command: 'teardown' + stack_dir: 'examples/aws-ssm-parameter' stack_env: 'dev' - env_vars: 'GOOGLE_PROJECT=stackql-k8s-the-hard-way-demo' - # log_level: 'debug' - output_file: 'deployment-outputs.json' + env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}' + log_level: 'info' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d124f27 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +stackql* +.stackql/ +.env +.claude \ No newline at end of file diff --git a/README.md b/README.md index 0ab6d50..292a405 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Deploy a Stack uses: stackql/stackql-deploy-action@v1.0.2 @@ -69,7 +69,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Deploy a Stack id: stackql-deploy diff --git a/action.yml b/action.yml index 9f127e6..c7e8932 100644 --- a/action.yml +++ b/action.yml @@ -1,15 +1,15 @@ name: 'stackql-deploy' -description: 'Deploy and test stacks using stackql-deploy' +description: 'Deploy and test stacks using stackql-deploy (Rust edition)' inputs: command: - description: 'stackql-deploy command to run (`build` or `test`)' + description: 'stackql-deploy command to run (`build`, `test`, `teardown`, or `info`)' required: true stack_dir: description: 'repo directory containing `stackql_manifest.yml` and `resources` dir' - required: true + required: false stack_env: description: 'environment to deploy or test (e.g., `dev`, `prod`)' - required: true + required: false env_vars: description: 'environment variables or secrets imported into a stack (format: `KEY=value,KEY2=value2`)' required: false @@ -20,22 +20,19 @@ inputs: description: 'show queries run in the output logs' required: false log_level: - description: 'set the logging level (`INFO` or `DEBUG`, defaults to `INFO`)' - required: false + description: 'set the logging level (`info`, `debug`, `trace`, `warn`, or `error`, defaults to `info`)' + required: false dry_run: description: 'perform a dry run of the operation' required: false - custom_registry: - description: 'custom registry URL to be used for stackql' - required: false on_failure: - description: 'action on failure' + description: 'action on failure (`error`, `rollback`, or `ignore`, defaults to `error`)' required: false show_info: - description: 'show stackql-deploy info output' + description: 'show stackql-deploy info output before running the command' required: false output_file: - description: 'output file to capture deployment outputs (JSON format)' + description: 'output file to capture deployment outputs as JSON (supported for `build` command only)' required: false outputs: @@ -46,14 +43,47 @@ outputs: runs: using: 'composite' steps: - - name: Install Python - uses: actions/setup-python@v6.0.0 - with: - python-version: '3.13' - - name: Install stackql-deploy shell: bash - run: pip install -q stackql-deploy pyyaml || { echo "pip install failed"; exit 1; } + run: | + if command -v stackql-deploy &> /dev/null; then + echo "stackql-deploy already installed: $(stackql-deploy --version 2>/dev/null || echo 'version unknown')" + else + echo "Installing stackql-deploy binary..." + OS="$(uname -s)" + ARCH="$(uname -m)" + BASE_URL="https://github.com/stackql/stackql-deploy-rs/releases/latest/download" + echo "Detected platform: ${OS}-${ARCH}" + case "${OS}-${ARCH}" in + Linux-x86_64) URL="${BASE_URL}/stackql-deploy-linux-x86_64.tar.gz" ;; + Linux-aarch64) URL="${BASE_URL}/stackql-deploy-linux-arm64.tar.gz" ;; + Darwin-arm64) URL="${BASE_URL}/stackql-deploy-macos-arm64.tar.gz" ;; + Darwin-x86_64) URL="${BASE_URL}/stackql-deploy-macos-x86_64.tar.gz" ;; + MINGW*|MSYS*|CYGWIN*) + URL="${BASE_URL}/stackql-deploy-windows-x86_64.zip" ;; + *) + echo "Unsupported platform: ${OS}-${ARCH}" + exit 1 + ;; + esac + echo "Download URL: ${URL}" + + if [[ "$OS" == MINGW* || "$OS" == MSYS* || "$OS" == CYGWIN* ]]; then + curl -L -o stackql-deploy.zip "$URL" + unzip -o stackql-deploy.zip + rm -f stackql-deploy.zip + else + curl -L "$URL" | tar -xz + fi + + chmod +x ./stackql-deploy + echo "Binary details: $(file ./stackql-deploy)" + echo "${GITHUB_WORKSPACE}" >> "$GITHUB_PATH" + export PATH="${GITHUB_WORKSPACE}:${PATH}" + + echo "stackql-deploy installed:" + ./stackql-deploy info + fi - name: Run stackql-deploy id: stackql-deploy @@ -66,6 +96,13 @@ runs: echo "" fi + # Handle info command (no stack_dir/stack_env needed) + if [ "${{ inputs.command }}" == "info" ]; then + stackql-deploy info + exit 0 + fi + + # Build env var options (-e KEY=VALUE ...) ENV_OPTS="" if [ -n "${{ inputs.env_vars }}" ]; then IFS=',' read -r -a env_array <<< "${{ inputs.env_vars }}" @@ -74,7 +111,15 @@ runs: done fi - STACKQL_DEPLOY_CMD="stackql-deploy ${{ inputs.command }} ${{ inputs.stack_dir }} ${{ inputs.stack_env }}" + STACKQL_DEPLOY_CMD="stackql-deploy ${{ inputs.command }}" + + # Append positional args only when provided + if [ -n "${{ inputs.stack_dir }}" ]; then + STACKQL_DEPLOY_CMD+=" ${{ inputs.stack_dir }}" + fi + if [ -n "${{ inputs.stack_env }}" ]; then + STACKQL_DEPLOY_CMD+=" ${{ inputs.stack_env }}" + fi if [ -n "${{ inputs.env_file }}" ]; then STACKQL_DEPLOY_CMD+=" --env-file ${{ inputs.env_file }}" @@ -88,28 +133,25 @@ runs: if [ "${{ inputs.dry_run }}" == "true" ]; then STACKQL_DEPLOY_CMD+=" --dry-run" fi - if [ -n "${{ inputs.custom_registry }}" ]; then - STACKQL_DEPLOY_CMD+=" --custom-registry ${{ inputs.custom_registry }}" - fi if [ -n "${{ inputs.on_failure }}" ]; then STACKQL_DEPLOY_CMD+=" --on-failure ${{ inputs.on_failure }}" fi - - # Handle output file + + # --output-file is only supported by the build command OUTPUT_FILE="" - if [ -n "${{ inputs.output_file }}" ]; then + if [ -n "${{ inputs.output_file }}" ] && [ "${{ inputs.command }}" == "build" ]; then OUTPUT_FILE="${{ inputs.output_file }}" STACKQL_DEPLOY_CMD+=" --output-file $OUTPUT_FILE" fi echo "executing: $STACKQL_DEPLOY_CMD $ENV_OPTS" - + # Run command and capture exit code set +e $STACKQL_DEPLOY_CMD $ENV_OPTS EXIT_CODE=$? set -e - + # Handle failure if [ $EXIT_CODE -ne 0 ]; then echo "## ❌ StackQL Deploy ${{ inputs.command }} Failed" >> $GITHUB_STEP_SUMMARY @@ -123,24 +165,18 @@ runs: exit $EXIT_CODE fi - # Capture outputs if output file was specified (success path) + # Capture outputs if output file was specified (build command, success path) if [ -n "$OUTPUT_FILE" ] && [ -f "$OUTPUT_FILE" ]; then - # Read the JSON content DEPLOYMENT_OUTPUTS=$(cat "$OUTPUT_FILE") - - # Set the outputs for the action + echo "deployment_outputs<> $GITHUB_OUTPUT echo "$DEPLOYMENT_OUTPUTS" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT - - # Add to job summary with formatted output + echo "## 📦 StackQL Deploy ${{ inputs.command }}:" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - - # Parse and display each key-value pair echo "$DEPLOYMENT_OUTPUTS" | jq -r 'to_entries[] | "**\(.key):** \(.value)"' >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo "_Completed at $(date -u +'%Y-%m-%d %H:%M:%S UTC')_" >> $GITHUB_STEP_SUMMARY echo "Deployment outputs captured successfully" diff --git a/examples/aws-ssm-parameter/resources/aws/ssm/parameters.iql b/examples/aws-ssm-parameter/resources/aws/ssm/parameters.iql new file mode 100644 index 0000000..dda1358 --- /dev/null +++ b/examples/aws-ssm-parameter/resources/aws/ssm/parameters.iql @@ -0,0 +1,70 @@ +/*+ exists */ +SELECT count(*) as count +FROM awscc.ssm.parameters +WHERE region = '{{ region }}' AND +Identifier = '{{ name }}' +; + +/*+ create */ +INSERT INTO awscc.ssm.parameters ( + Type, + Value, + Description, + Tier, + Tags, + DataType, + Name, + region +) +SELECT + '{{ type }}', + '{{ value }}', + '{{ description }}', + '{{ tier }}', + '{{ tags }}', + '{{ data_type }}', + '{{ name }}', + '{{ region }}'; + +/*+ update */ +UPDATE awscc.ssm.parameters +SET PatchDocument = string('{{ { + "Type": type, + "Value": value, + "Description": description, + "Tier": tier, + "Tags": tags, + "DataType": data_type +} | generate_patch_document }}') +WHERE + region = '{{ region }}' AND + Identifier = '{{ name }}'; + +/*+ statecheck, retries=5, retry_delay=10 */ +SELECT count(*) as count +FROM awscc.ssm.parameters +WHERE +region = '{{ region }}' AND +Identifier = '{{ name }}' +; + +/*+ exports */ +SELECT +type, +value, +description, +policies, +allowed_pattern, +tier, +tags, +data_type, +name +FROM awscc.ssm.parameters +WHERE region = '{{ region }}' AND +Identifier = '{{ name }}'; + +/*+ delete */ +DELETE FROM awscc.ssm.parameters +WHERE + Identifier = '{{ name }}' AND + region = '{{ region }}'; diff --git a/examples/aws-ssm-parameter/stackql_manifest.yml b/examples/aws-ssm-parameter/stackql_manifest.yml new file mode 100644 index 0000000..6847ea9 --- /dev/null +++ b/examples/aws-ssm-parameter/stackql_manifest.yml @@ -0,0 +1,36 @@ +version: 1 +name: "stackql-deploy-action-test" +description: SSM parameter test stack for stackql-deploy-action CI validation +providers: + - awscc +globals: + - name: region + description: aws region + value: "{{ AWS_REGION }}" + - name: global_tags + value: + 'stackql:stack-name': "{{ stack_name }}" + 'stackql:stack-env': "{{ stack_env }}" + 'stackql:resource-name': "{{ resource_name }}" +resources: + - name: test_ssm_parameter + file: aws/ssm/parameters.iql + props: + - name: name + value: "/{{ stack_name }}/{{ stack_env }}/test-param" + - name: type + value: "String" + - name: value + value: "stackql-deploy-action-test-value-updated" + - name: description + value: "Test SSM parameter for stackql-deploy-action CI" + - name: tier + value: "Standard" + - name: tags + value: "{{ global_tags }}" + - name: data_type + value: "text" + exports: + - name + - value + - type diff --git a/examples/k8s-the-hard-way/README.md b/examples/k8s-the-hard-way/README.md deleted file mode 100644 index 6cee363..0000000 --- a/examples/k8s-the-hard-way/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# example `stackql-deploy` stack - -Based upon the [Kubernetes the Hard Way](https://github.com/kelseyhightower/kubernetes-the-hard-way) project. - -## about `stackql-deploy` - -[`stackql-deploy`](https://pypi.org/project/stackql-deploy/) is a multi cloud deployment automation and testing framework which is an alternative to Terraform or similar IaC tools. `stackql-deploy` uses a declarative model/ELT based approach to cloud resource deployment (inspired by [`dbt`](https://www.getdbt.com/)). Advantages of `stackql-deploy` include: - -- declarative framework -- no state file (state is determined from the target environment) -- multi-cloud/omni-cloud ready -- includes resource tests which can include secure config tests - -## instaling `stackql-deploy` - -`stackql-deploy` is installed as a python based CLI using... - -```bash -pip install stackql-deploy -``` - -## getting started with `stackql-deploy` - -Once installed, use the `init` command to scaffold a sample project directory to get started: - -```bash -stackql-deploy init k8s-the-hard-way -``` - -this will create a directory named `k8s-the-hard-way` which can be updated for your stack, as you can see in this project. - -## deploying using `stackql-deploy` - -```bash -export GOOGLE_CREDENTIALS=$(cat ./creds.json) -# deploy a stack -stackql-deploy build \ -k8s-the-hard-way \ -dev \ --e GOOGLE_PROJECT=stackql-k8s-the-hard-way-demo \ ---dry-run \ ---log-leve DEBUG - -# test a stack -stackql-deploy test \ -examples/k8s-the-hard-way \ -dev \ --e GOOGLE_PROJECT=stackql-k8s-the-hard-way-demo \ ---dry-run - -# teardown a stack -stackql-deploy teardown \ -k8s-the-hard-way \ -dev \ --e GOOGLE_PROJECT=stackql-k8s-the-hard-way-demo \ ---dry-run -``` diff --git a/examples/k8s-the-hard-way/resources/firewalls.iql b/examples/k8s-the-hard-way/resources/firewalls.iql deleted file mode 100644 index c936034..0000000 --- a/examples/k8s-the-hard-way/resources/firewalls.iql +++ /dev/null @@ -1,33 +0,0 @@ -/*+ preflight */ -SELECT COUNT(*) as count FROM google.compute.firewalls -WHERE project = '{{ project }}' -AND name = '{{ fw_name }}' - -/*+ create */ -INSERT INTO google.compute.firewalls -( - project, - data__name, - data__network, - data__direction, - data__sourceRanges, - data__allowed -) -SELECT - '{{ project }}', - '{{ fw_name}}', - '{{ vpc_link }}', - '{{ fw_direction }}', - '{{ fw_source_ranges }}', - '{{ fw_allowed }}' - -/*+ postdeploy, retries=5, retry_delay=10 */ -SELECT COUNT(*) as count FROM google.compute.firewalls -WHERE project = '{{ project }}' -AND name = '{{ fw_name }}' -AND network = '{{ vpc_link }}' - -/*+ delete, retries=20, retry_delay=10 */ -DELETE FROM google.compute.firewalls -WHERE project = '{{ project }}' -AND firewall = '{{ fw_name }}' \ No newline at end of file diff --git a/examples/k8s-the-hard-way/resources/forwarding_rule.iql b/examples/k8s-the-hard-way/resources/forwarding_rule.iql deleted file mode 100644 index 2eefe16..0000000 --- a/examples/k8s-the-hard-way/resources/forwarding_rule.iql +++ /dev/null @@ -1,36 +0,0 @@ -/*+ preflight */ -SELECT COUNT(*) as count FROM google.compute.forwarding_rules -WHERE region = '{{ region }}' -AND project = '{{ project }}' -AND forwardingRule = '{{ forwarding_rule_name }}' - -/*+ create */ -INSERT INTO google.compute.forwarding_rules( - project, - region, - data__name, - data__IPAddress, - data__loadBalancingScheme, - data__portRange, - data__target -) -SELECT - '{{ project }}', - '{{ region }}', - '{{ forwarding_rule_name }}', - '{{ address }}', - '{{ forwarding_rule_load_balancing_scheme }}', - '{{ forwarding_rule_port_range }}', - '{{ target_pool_link }}' - -/*+ postdeploy, retries=5, retry_delay=10 */ -SELECT COUNT(*) as count FROM google.compute.forwarding_rules -WHERE region = '{{ region }}' -AND project = '{{ project }}' -AND forwardingRule = '{{ forwarding_rule_name }}' - -/*+ delete, retries=20, retry_delay=10 */ -DELETE FROM google.compute.forwarding_rules -WHERE project = '{{ project }}' - AND region = '{{ region }}' - AND forwardingRule = '{{ forwarding_rule_name }}' \ No newline at end of file diff --git a/examples/k8s-the-hard-way/resources/get_controller_instances.iql b/examples/k8s-the-hard-way/resources/get_controller_instances.iql deleted file mode 100644 index 36d7aef..0000000 --- a/examples/k8s-the-hard-way/resources/get_controller_instances.iql +++ /dev/null @@ -1,6 +0,0 @@ -/*+ exports */ -SELECT JSON_GROUP_ARRAY(json_object('instance', selfLink)) as controller_instances -FROM google.compute.instances -WHERE project = '{{ project }}' -AND zone = '{{ default_zone }}' -AND name like '%-{{ stack_env }}-controller-%' \ No newline at end of file diff --git a/examples/k8s-the-hard-way/resources/health_checks.iql b/examples/k8s-the-hard-way/resources/health_checks.iql deleted file mode 100644 index 1db865e..0000000 --- a/examples/k8s-the-hard-way/resources/health_checks.iql +++ /dev/null @@ -1,45 +0,0 @@ -/*+ preflight */ -SELECT COUNT(*) as count FROM google.compute.http_health_checks -WHERE project = '{{ project }}' -AND httpHealthCheck = '{{ health_check_name }}' - -/*+ create */ -INSERT INTO google.compute.http_health_checks( - project, - data__name, - data__checkIntervalSec, - data__description, - data__healthyThreshold, - data__host, - data__port, - data__requestPath, - data__timeoutSec, - data__unhealthyThreshold -) -SELECT - '{{ project }}', - '{{ health_check_name }}', - {{ health_check_interval_sec }}, - '{{ health_check_description }}', - {{ health_check_healthy_threshold }}, - '{{ health_check_host }}', - {{ health_check_port }}, - '{{ health_check_path }}', - {{ health_check_timeout_sec }}, - {{ health_check_unhealthy_threshold }} - -/*+ postdeploy, retries=5, retry_delay=10 */ -SELECT COUNT(*) as count FROM google.compute.http_health_checks -WHERE project = '{{ project }}' -AND httpHealthCheck = '{{ health_check_name }}' - -/*+ delete, retries=20, retry_delay=10 */ -DELETE FROM google.compute.http_health_checks -WHERE project = '{{ project }}' -AND httpHealthCheck = '{{ health_check_name }}' - -/*+ exports */ -SELECT selfLink as health_check_link -FROM google.compute.http_health_checks -WHERE project = '{{ project }}' -AND httpHealthCheck = '{{ health_check_name }}' \ No newline at end of file diff --git a/examples/k8s-the-hard-way/resources/instances.iql b/examples/k8s-the-hard-way/resources/instances.iql deleted file mode 100644 index 7ca29f3..0000000 --- a/examples/k8s-the-hard-way/resources/instances.iql +++ /dev/null @@ -1,60 +0,0 @@ -/*+ preflight */ -SELECT - CASE - WHEN COUNT(*) = {{ num_instances | int }} THEN 1 - ELSE 0 - END AS count -FROM google.compute.instances -WHERE project = '{{ project }}' -AND zone = '{{ default_zone }}' -AND instance IN ({% for i in range(num_instances | int) %}'{{ instance_name_prefix }}-{{ loop.index }}'{% if not loop.last %}, {% endif %}{% endfor %}) - -/*+ create */ -{% for network_interface in network_interfaces %} -INSERT INTO google.compute.instances - ( - zone, - project, - data__name, - data__machineType, - data__canIpForward, - data__deletionProtection, - data__scheduling, - data__networkInterfaces, - data__disks, - data__serviceAccounts, - data__tags - ) - SELECT -'{{ default_zone }}', -'{{ project }}', -'{{ instance_name_prefix }}-{{ loop.index }}', -'{{ machine_type }}', -true, -false, -'{{ scheduling | tojson }}', -'{{ network_interface | tojson }}', -'{{ disks | tojson }}', -'{{ service_accounts | tojson }}', -'{{ tags | tojson }}'; -{% endfor %} - -/*+ postdeploy, retries=5, retry_delay=10 */ -SELECT - CASE - WHEN COUNT(*) = {{ num_instances | int }} THEN 1 - ELSE 0 - END AS count -FROM google.compute.instances -WHERE project = '{{ project }}' -AND zone = '{{ default_zone }}' -AND status = 'RUNNING' -AND instance IN ({% for i in range(num_instances | int) %}'{{ instance_name_prefix }}-{{ loop.index }}'{% if not loop.last %}, {% endif %}{% endfor %}) - -/*+ delete */ -{% for network_interface in network_interfaces %} -DELETE FROM google.compute.instances -WHERE project = '{{ project }}' -AND zone = '{{ default_zone }}' -AND instance = '{{ instance_name_prefix }}-{{ loop.index }}'; -{% endfor %} \ No newline at end of file diff --git a/examples/k8s-the-hard-way/resources/network.iql b/examples/k8s-the-hard-way/resources/network.iql deleted file mode 100644 index de84c88..0000000 --- a/examples/k8s-the-hard-way/resources/network.iql +++ /dev/null @@ -1,43 +0,0 @@ -/*+ preflight */ -SELECT COUNT(*) as count FROM google.compute.networks -WHERE name = '{{ vpc_name }}' -AND project = '{{ project }}' - -/*+ create */ -INSERT INTO google.compute.networks -( - project, - data__name, - data__autoCreateSubnetworks, - data__routingConfig -) -SELECT -'{{ project }}', -'{{ vpc_name }}', -false, -'{"routingMode": "REGIONAL"}' - -/*+ update */ -UPDATE google.compute.networks -SET data__autoCreateSubnetworks = false -AND data__routingConfig = '{"routingMode": "REGIONAL"}' -WHERE network = '{{ vpc_name }}' AND project = '{{ project }}' - -/*+ postdeploy, retries=5, retry_delay=10 */ -SELECT COUNT(*) as count FROM google.compute.networks -WHERE name = '{{ vpc_name }}' -AND project = '{{ project }}' -AND autoCreateSubnetworks = false -AND JSON_EXTRACT(routingConfig, '$.routingMode') = 'REGIONAL' - -/*+ delete, retries=20, retry_delay=10 */ -DELETE FROM google.compute.networks -WHERE network = '{{ vpc_name }}' AND project = '{{ project }}' - -/*+ exports */ -SELECT -'{{ vpc_name }}' as vpc_name, -selfLink as vpc_link -FROM google.compute.networks -WHERE name = '{{ vpc_name }}' -AND project = '{{ project }}' diff --git a/examples/k8s-the-hard-way/resources/public_address.iql b/examples/k8s-the-hard-way/resources/public_address.iql deleted file mode 100644 index d187748..0000000 --- a/examples/k8s-the-hard-way/resources/public_address.iql +++ /dev/null @@ -1,35 +0,0 @@ -/*+ preflight */ -SELECT COUNT(*) as count FROM google.compute.addresses -WHERE name = '{{ address_name }}' -AND project = '{{ project }}' -AND region = '{{ region }}' - -/*+ create */ -INSERT INTO google.compute.addresses -( - project, - region, - data__name -) -SELECT -'{{ project }}', -'{{ region }}', -'{{ address_name }}' - -/*+ postdeploy, retries=5, retry_delay=10 */ -SELECT COUNT(*) as count FROM google.compute.addresses -WHERE name = '{{ address_name }}' -AND project = '{{ project }}' -AND region = '{{ region }}' - -/*+ delete */ -DELETE FROM google.compute.addresses -WHERE address = '{{ address_name }}' AND project = '{{ project }}' -AND region = '{{ region }}' - -/*+ exports */ -SELECT address -FROM google.compute.addresses -WHERE name = '{{ address_name }}' -AND project = '{{ project }}' -AND region = '{{ region }}' diff --git a/examples/k8s-the-hard-way/resources/routes.iql b/examples/k8s-the-hard-way/resources/routes.iql deleted file mode 100644 index a1b24e1..0000000 --- a/examples/k8s-the-hard-way/resources/routes.iql +++ /dev/null @@ -1,45 +0,0 @@ -/*+ preflight */ -SELECT - CASE - WHEN COUNT(*) = {{ num_routes | int }} THEN 1 - ELSE 0 - END AS count -FROM google.compute.routes -WHERE project = '{{ project }}' -AND route IN ({% for i in range(num_routes | int) %}'{{ route_name_prefix }}-{{ loop.index }}'{% if not loop.last %}, {% endif %}{% endfor %}) - -/*+ create */ -{% for route in route_data %} -INSERT INTO google.compute.routes( - project, - data__destRange, - data__name, - data__network, - data__nextHopIp, - data__priority -) -SELECT - '{{ project }}', - '{{ route.dest_range }}', - '{{ route_name_prefix }}-{{ loop.index }}', - '{{ vpc_link }}', - '{{ route.next_hop_ip }}', - {{ route_priority }}; -{% endfor %} - -/*+ postdeploy, retries=5, retry_delay=10 */ -SELECT - CASE - WHEN COUNT(*) = {{ num_routes | int }} THEN 1 - ELSE 0 - END AS count -FROM google.compute.routes -WHERE project = '{{ project }}' -AND route IN ({% for i in range(num_routes | int) %}'{{ route_name_prefix }}-{{ loop.index }}'{% if not loop.last %}, {% endif %}{% endfor %}) - -/*+ delete, retries=20, retry_delay=10 */ -{% for route in route_data %} -DELETE FROM google.compute.routes -WHERE project = '{{ project }}' -AND route = '{{ route_name_prefix }}-{{ loop.index }}'; -{% endfor %} \ No newline at end of file diff --git a/examples/k8s-the-hard-way/resources/subnetwork.iql b/examples/k8s-the-hard-way/resources/subnetwork.iql deleted file mode 100644 index c66f5bb..0000000 --- a/examples/k8s-the-hard-way/resources/subnetwork.iql +++ /dev/null @@ -1,54 +0,0 @@ -/*+ preflight */ -SELECT COUNT(*) as count FROM google.compute.subnetworks -WHERE subnetwork = '{{ subnet_name }}' -AND project = '{{ project }}' -AND region = '{{ region }}' -AND network = '{{ vpc_link }}' - -/*+ create */ -INSERT INTO google.compute.subnetworks -( - project, - region, - data__name, - data__network, - data__ipCidrRange, - data__privateIpGoogleAccess -) -SELECT -'{{ project }}', -'{{ region }}', -'{{ subnet_name }}', -'{{ vpc_link }}', -'{{ ip_cidr_range }}', -true - -/*+ update */ -UPDATE google.compute.subnetworks -SET -data__name = '{{ subnet_name }}', -data__network = '{{ vpc_link }}', -data__ipCidrRange = '{{ ip_cidr_range }}', -data__privateIpGoogleAccess = true -WHERE subnetwork = '{{ subnet_name }}' -AND project = '{{ project }}' -AND region = '{{ region }}' - -/*+ postdeploy, retries=5, retry_delay=10 */ -SELECT COUNT(*) as count FROM google.compute.subnetworks_usable -WHERE project = '{{ project }}' -AND subnetwork = 'https://www.googleapis.com/compute/v1/projects/{{ project }}/regions/{{ region }}/subnetworks/{{ subnet_name }}' - -/*+ delete */ -DELETE FROM google.compute.subnetworks -WHERE subnetwork = '{{ subnet_name }}' AND project = '{{ project }}' -AND region = '{{ region }}' - -/*+ exports */ -SELECT -name as subnet_name, -selfLink as subnet_link -FROM google.compute.subnetworks -WHERE subnetwork = '{{ subnet_name }}' -AND project = '{{ project }}' -AND region = '{{ region }}' diff --git a/examples/k8s-the-hard-way/resources/target_pool.iql b/examples/k8s-the-hard-way/resources/target_pool.iql deleted file mode 100644 index 4ad4a27..0000000 --- a/examples/k8s-the-hard-way/resources/target_pool.iql +++ /dev/null @@ -1,42 +0,0 @@ -/*+ preflight */ -SELECT COUNT(*) as count FROM google.compute.target_pools -WHERE project = '{{ project }}' - AND region = '{{ region }}' - AND targetPool = '{{ target_pool_name }}' - -/*+ create */ -INSERT INTO google.compute.target_pools( - project, - region, - data__name, - data__healthChecks, - data__instances, - data__sessionAffinity -) -SELECT - '{{ project }}', - '{{ region }}', - '{{ target_pool_name }}', - '{{ target_pool_health_checks }}', - '{{ target_pool_instances }}', - '{{ target_pool_session_affinity }}' - -/*+ postdeploy, retries=5, retry_delay=10 */ -SELECT COUNT(*) as count FROM google.compute.target_pools -WHERE project = '{{ project }}' - AND region = '{{ region }}' - AND targetPool = '{{ target_pool_name }}' - -/*+ delete, retries=20, retry_delay=10 */ -DELETE FROM google.compute.target_pools -WHERE project = '{{ project }}' - AND region = '{{ region }}' - AND targetPool = '{{ target_pool_name }}' - -/*+ exports */ -SELECT -selfLink as target_pool_link -FROM google.compute.target_pools -WHERE targetPool = '{{ target_pool_name }}' -AND project = '{{ project }}' -AND region = '{{ region }}' diff --git a/examples/k8s-the-hard-way/stackql_manifest.yml b/examples/k8s-the-hard-way/stackql_manifest.yml deleted file mode 100644 index 10939f0..0000000 --- a/examples/k8s-the-hard-way/stackql_manifest.yml +++ /dev/null @@ -1,222 +0,0 @@ -version: 1 -name: kubernetes-the-hard-way -description: stackql-deploy example for kubernetes-the-hard-way -providers: - - google -globals: -- name: project - description: google project name - value: "{{ GOOGLE_PROJECT }}" -- name: region - value: australia-southeast1 -- name: default_zone - value: australia-southeast1-a -resources: -- name: network - description: vpc network for k8s-the-hard-way sample app - props: - - name: vpc_name - description: name for the vpc - value: "{{ stack_name }}-{{ stack_env }}-vpc" - exports: - - vpc_name - - vpc_link -- name: subnetwork - props: - - name: subnet_name - value: "{{ stack_name }}-{{ stack_env }}-{{ region }}-subnet" - - name: ip_cidr_range - values: - prd: - value: 192.168.0.0/16 - sit: - value: 10.10.0.0/16 - dev: - value: 10.240.0.0/24 - exports: - - subnet_name - - subnet_link -# - name: public_address -# props: -# - name: address_name -# value: "{{ stack_name }}-{{ stack_env }}-{{ region }}-ip-addr" -# exports: -# - address -# - name: controller_instances -# file: instances.iql -# props: -# - name: num_instances -# value: 3 -# - name: instance_name_prefix -# value: "{{ stack_name }}-{{ stack_env }}-controller" -# - name: disks -# value: -# - autoDelete: true -# boot: true -# initializeParams: -# diskSizeGb: 10 -# sourceImage: https://compute.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/family/ubuntu-2004-lts -# mode: READ_WRITE -# type: PERSISTENT -# - name: machine_type -# value: "https://compute.googleapis.com/compute/v1/projects/{{ project }}/zones/{{ default_zone }}/machineTypes/f1-micro" -# - name: scheduling -# value: {automaticRestart: true} -# - name: tags -# value: {items: ["{{ stack_name }}", "controller"]} -# - name: service_accounts -# value: -# - email: default -# scopes: -# - https://www.googleapis.com/auth/compute -# - https://www.googleapis.com/auth/devstorage.read_only -# - https://www.googleapis.com/auth/logging.write -# - https://www.googleapis.com/auth/monitoring -# - https://www.googleapis.com/auth/service.management.readonly -# - https://www.googleapis.com/auth/servicecontrol -# - name: network_interfaces -# values: -# dev: -# value: -# - {networkIP: "10.240.0.10", subnetwork: "{{ subnet_link }}", accessConfigs: [{name: external-nat, type: ONE_TO_ONE_NAT}]} -# - {networkIP: "10.240.0.11", subnetwork: "{{ subnet_link }}", accessConfigs: [{name: external-nat, type: ONE_TO_ONE_NAT}]} -# - {networkIP: "10.240.0.12", subnetwork: "{{ subnet_link }}", accessConfigs: [{name: external-nat, type: ONE_TO_ONE_NAT}]} -# - name: worker_instances -# file: instances.iql -# props: -# - name: num_instances -# value: 3 -# - name: instance_name_prefix -# value: "{{ stack_name }}-{{ stack_env }}-worker" -# - name: disks -# value: -# - autoDelete: true -# boot: true -# initializeParams: -# diskSizeGb: 10 -# sourceImage: https://compute.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/family/ubuntu-2004-lts -# mode: READ_WRITE -# type: PERSISTENT -# - name: machine_type -# value: "https://compute.googleapis.com/compute/v1/projects/{{ project }}/zones/{{ default_zone }}/machineTypes/f1-micro" -# - name: scheduling -# value: {automaticRestart: true} -# - name: tags -# value: {items: ["{{ stack_name }}", "worker"]} -# - name: service_accounts -# value: -# - email: default -# scopes: -# - https://www.googleapis.com/auth/compute -# - https://www.googleapis.com/auth/devstorage.read_only -# - https://www.googleapis.com/auth/logging.write -# - https://www.googleapis.com/auth/monitoring -# - https://www.googleapis.com/auth/service.management.readonly -# - https://www.googleapis.com/auth/servicecontrol -# - name: network_interfaces -# values: -# dev: -# value: -# - {networkIP: "10.240.0.20", subnetwork: "{{ subnet_link }}", accessConfigs: [{name: external-nat, type: ONE_TO_ONE_NAT}]} -# - {networkIP: "10.240.0.21", subnetwork: "{{ subnet_link }}", accessConfigs: [{name: external-nat, type: ONE_TO_ONE_NAT}]} -# - {networkIP: "10.240.0.22", subnetwork: "{{ subnet_link }}", accessConfigs: [{name: external-nat, type: ONE_TO_ONE_NAT}]} -# - name: health_checks -# props: -# - name: health_check_name -# value: kubernetes -# - name: health_check_interval_sec -# value: 5 -# - name: health_check_description -# value: Kubernetes Health Check -# - name: health_check_timeout_sec -# value: 5 -# - name: health_check_healthy_threshold -# value: 2 -# - name: health_check_unhealthy_threshold -# value: 2 -# - name: health_check_host -# value: kubernetes.default.svc.cluster.local -# - name: health_check_port -# value: 80 -# - name: health_check_path -# value: /healthz -# exports: -# - health_check_link -# - name: internal_firewall -# file: firewalls.iql -# props: -# - name: fw_name -# value: "{{ stack_name }}-{{ stack_env }}-allow-internal-fw" -# - name: fw_direction -# value: INGRESS -# - name: fw_source_ranges -# values: -# dev: -# value: ["10.240.0.0/24", "10.200.0.0/16"] -# - name: fw_allowed -# value: [{IPProtocol: tcp}, {IPProtocol: udp}, {IPProtocol: icmp}] -# - name: external_firewall -# file: firewalls.iql -# props: -# - name: fw_name -# value: "{{ stack_name }}-{{ stack_env }}-allow-external-fw" -# - name: fw_direction -# value: INGRESS -# - name: fw_source_ranges -# values: -# dev: -# value: ["0.0.0.0/0"] -# - name: fw_allowed -# value: [{IPProtocol: tcp, ports: ["22"]}, {IPProtocol: tcp, ports: ["6443"]},{IPProtocol: icmp}] -# - name: health_check_firewall -# file: firewalls.iql -# props: -# - name: fw_name -# value: "{{ stack_name }}-{{ stack_env }}-allow-health-check-fw" -# - name: fw_direction -# value: INGRESS -# - name: fw_source_ranges -# values: -# dev: -# value: ["209.85.152.0/22", "209.85.204.0/22", "35.191.0.0/16"] -# - name: fw_allowed -# value: [{IPProtocol: tcp}] -# - name: get_controller_instances -# type: query -# exports: -# - controller_instances -# - name: target_pool -# props: -# - name: target_pool_name -# value: "{{ stack_name }}-{{ stack_env }}-target-pool" -# - name: target_pool_session_affinity -# value: NONE -# - name: target_pool_health_checks -# value: ["{{ health_check_link }}"] -# - name: target_pool_instances -# value: "{{ controller_instances }}" -# exports: -# - target_pool_link -# - name: forwarding_rule -# props: -# - name: forwarding_rule_name -# value: "{{ stack_name }}-{{ stack_env }}-forwarding-rule" -# - name: forwarding_rule_load_balancing_scheme -# value: EXTERNAL -# - name: forwarding_rule_port_range -# value: 6443 -# - name: routes -# props: -# - name: num_routes -# value: 3 -# - name: route_name_prefix -# value: "{{ stack_name }}-{{ stack_env }}-route" -# - name: route_priority -# value: 1000 -# - name: route_data -# values: -# dev: -# value: -# - {dest_range: "10.200.0.0/24", next_hop_ip: "10.240.0.20"} -# - {dest_range: "10.200.1.0/24", next_hop_ip: "10.240.0.21"} -# - {dest_range: "10.200.2.0/24", next_hop_ip: "10.240.0.22"} diff --git a/examples/workflow-with-outputs.yml b/examples/workflow-with-outputs.yml deleted file mode 100644 index c351f23..0000000 --- a/examples/workflow-with-outputs.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: StackQL Deploy with Outputs Example -on: - push: - branches: [main] - workflow_dispatch: - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Deploy with StackQL - id: stackql-deploy - uses: stackql/stackql-deploy-action@main - with: - command: 'build' - stack_dir: './examples/k8s-the-hard-way' - stack_env: 'prod' - output_file: 'deployment-outputs.json' - env_vars: 'PROJECT_ID=${{ secrets.GOOGLE_PROJECT_ID }},REGION=us-central1' - - - name: Display deployment outputs - run: | - echo "Deployment completed successfully!" - echo "Output file: ${{ steps.stackql-deploy.outputs.deployment_outputs_file }}" - echo "Raw outputs: ${{ steps.stackql-deploy.outputs.deployment_outputs }}" - - - name: Parse specific output values - run: | - # Parse specific values from the JSON output - WORKSPACE_NAME=$(echo '${{ steps.stackql-deploy.outputs.deployment_outputs }}' | jq -r '.databricks_workspace_name // "N/A"') - WORKSPACE_ID=$(echo '${{ steps.stackql-deploy.outputs.deployment_outputs }}' | jq -r '.databricks_workspace_id // "N/A"') - WORKSPACE_STATUS=$(echo '${{ steps.stackql-deploy.outputs.deployment_outputs }}' | jq -r '.databricks_workspace_status // "N/A"') - - echo "Workspace Name: $WORKSPACE_NAME" - echo "Workspace ID: $WORKSPACE_ID" - echo "Workspace Status: $WORKSPACE_STATUS" - - # Add to GitHub Summary - echo "## Deployment Results" >> $GITHUB_STEP_SUMMARY - echo "| Property | Value |" >> $GITHUB_STEP_SUMMARY - echo "|----------|-------|" >> $GITHUB_STEP_SUMMARY - echo "| Workspace Name | $WORKSPACE_NAME |" >> $GITHUB_STEP_SUMMARY - echo "| Workspace ID | $WORKSPACE_ID |" >> $GITHUB_STEP_SUMMARY - echo "| Workspace Status | $WORKSPACE_STATUS |" >> $GITHUB_STEP_SUMMARY - - - name: Use outputs in another step - if: contains(steps.stackql-deploy.outputs.deployment_outputs, 'RUNNING') - run: | - echo "Workspace is running, proceeding with post-deployment tasks..." - # Add your post-deployment logic here - - - name: Upload deployment outputs as artifact - uses: actions/upload-artifact@v4 - with: - name: deployment-outputs - path: ${{ steps.stackql-deploy.outputs.deployment_outputs_file }} - retention-days: 30 - - post-deploy: - needs: deploy - runs-on: ubuntu-latest - if: success() - steps: - - name: Download deployment outputs - uses: actions/download-artifact@v4 - with: - name: deployment-outputs - - - name: Process outputs in separate job - run: | - echo "Processing deployment outputs in a separate job..." - if [ -f "deployment-outputs.json" ]; then - cat deployment-outputs.json - # Process the outputs as needed - fi \ No newline at end of file diff --git a/local_setup.sh b/local_setup.sh new file mode 100644 index 0000000..d2d33b5 --- /dev/null +++ b/local_setup.sh @@ -0,0 +1,2 @@ +curl -L https://bit.ly/stackql-deploy-amd64 | tar -xz +./stackql-deploy info \ No newline at end of file diff --git a/local_test.sh b/local_test.sh new file mode 100644 index 0000000..71fab4b --- /dev/null +++ b/local_test.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# local_test.sh - Run the same stackql-deploy steps as the GitHub Actions workflow locally. +# Prerequisites: +# 1. Run `source local_test_setup.sh` to download the stackql-deploy binary. +# 2. Ensure AWS credentials are exported (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN). +# 3. Ensure AWS_REGION is exported. +# 4. sed is available (used to update the manifest). + +set -euo pipefail + +STACKQL_DEPLOY="./stackql-deploy" +STACK_DIR="examples/aws-ssm-parameter" +STACK_ENV="dev" +LOG_LEVEL="info" +ENV_OPTS="-e AWS_REGION=${AWS_REGION:?AWS_REGION must be set}" + +run_step() { + local step_name="$1" + local command="$2" + echo "" + echo "========================================================================" + echo " ${step_name}" + echo "========================================================================" + echo "executing: ${STACKQL_DEPLOY} ${command} ${STACK_DIR} ${STACK_ENV} --log-level ${LOG_LEVEL} ${ENV_OPTS}" + ${STACKQL_DEPLOY} ${command} ${STACK_DIR} ${STACK_ENV} --log-level ${LOG_LEVEL} ${ENV_OPTS} +} + +# Step 1: Deploy +run_step "Step 1: Deploy SSM Parameter" "build" + +# Step 2: Test +run_step "Step 2: Test SSM Parameter" "test" + +# Step 3: Update manifest - change the parameter value +echo "" +echo "========================================================================" +echo " Step 3: Update Manifest - Update SSM Parameter Value" +echo "========================================================================" +MANIFEST="${STACK_DIR}/stackql_manifest.yml" +echo "executing: sed -i.bak 's/stackql-deploy-action-test-value/stackql-deploy-action-test-value-updated/' ${MANIFEST}" +sed -i.bak 's/stackql-deploy-action-test-value/stackql-deploy-action-test-value-updated/' "${MANIFEST}" +rm -f "${MANIFEST}.bak" +echo "" +echo "Updated manifest:" +cat "${STACK_DIR}/stackql_manifest.yml" + +# Step 4: Redeploy with updated manifest +run_step "Step 4: Redeploy SSM Parameter with Updated Value" "build" + +# Step 5: Test again after update +run_step "Step 5: Test SSM Parameter (Post-Update)" "test" + +# Step 6: Teardown (always run) +teardown() { + run_step "Step 6: Teardown SSM Parameter" "teardown" +} +trap teardown EXIT + +echo "" +echo "All steps completed successfully. Teardown will run on exit."