From 4406f0aed48bf009aa08eb82b167a0e4aa3ce564 Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Fri, 4 Sep 2026 18:40:48 +0530 Subject: [PATCH 1/2] Migrate from the localstack CLI to lstk --- .github/workflows/ci.yml | 11 ++++------- .github/workflows/cloud-pods.yml | 30 ++++++++++++------------------ .gitignore | 1 + .lstk/config.toml | 10 ++++++++++ Makefile | 21 ++++++++------------- README.md | 16 ++++++---------- 6 files changed, 41 insertions(+), 48 deletions(-) create mode 100644 .lstk/config.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51ce7c3..be550d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,16 +45,13 @@ jobs: --no-interactive snow connection list + - name: Install lstk + run: npm install -g @localstack/lstk + - name: Start LocalStack - uses: LocalStack/setup-localstack@v0.2.4 - with: - image-tag: 'latest' - use-pro: 'true' - configuration: LS_LOG=trace - install-awslocal: 'true' env: - IMAGE_NAME: localstack/snowflake:latest LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} + run: lstk start - name: Install dependencies run: | diff --git a/.github/workflows/cloud-pods.yml b/.github/workflows/cloud-pods.yml index ed5f3bf..512a8ff 100644 --- a/.github/workflows/cloud-pods.yml +++ b/.github/workflows/cloud-pods.yml @@ -48,16 +48,13 @@ jobs: run: | make install + - name: Install lstk + run: npm install -g @localstack/lstk + - name: Start LocalStack - uses: LocalStack/setup-localstack@main - with: - image-tag: 'latest' - use-pro: 'true' - configuration: LS_LOG=trace - install-awslocal: 'true' env: LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} - IMAGE_NAME: localstack/snowflake:latest + run: lstk start - name: Create Snowflake resources run: | @@ -80,13 +77,12 @@ jobs: env: LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} run: | - message="Cloud Pod created: smart-factory-app on $(date) with workflow run id: ${{ github.run_id }}" - localstack pod save smart-factory-app --message "$message" + lstk snapshot save pod:smart-factory-app - name: Show LocalStack Logs if: always() run: | - localstack logs + lstk logs test-cloud-pod: name: Test Cloud Pod @@ -96,21 +92,19 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 + - name: Install lstk + run: npm install -g @localstack/lstk + - name: Start LocalStack - uses: LocalStack/setup-localstack@main - with: - use-pro: 'true' - install-awslocal: 'true' env: - DEBUG: 1 - IMAGE_NAME: localstack/snowflake:latest LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} + run: lstk start - name: Load Cloud Pod env: LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} run: | - localstack pod load smart-factory-app + lstk snapshot load pod:smart-factory-app - name: Install dependencies run: | @@ -124,7 +118,7 @@ jobs: - name: Show LocalStack Logs if: always() run: | - localstack logs + lstk logs - name: Generate a Diagnostic Report if: failure() diff --git a/.gitignore b/.gitignore index 3043220..a0e109b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # LocalStack volume/ +.lstk/lstk.log # dbt diff --git a/.lstk/config.toml b/.lstk/config.toml new file mode 100644 index 0000000..e185895 --- /dev/null +++ b/.lstk/config.toml @@ -0,0 +1,10 @@ +[[containers]] +type = "snowflake" +tag = "latest" +port = "4566" +env = ["ci"] + +[env.ci] +DEBUG = "1" +SF_LOG = "trace" +LS_LOG = "trace" diff --git a/Makefile b/Makefile index d2d6bcb..ba213d0 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,8 @@ LATEST ?= false check: ## Check if all required prerequisites are installed @echo "Checking if all required prerequisites are installed..." @which snow > /dev/null 2>&1 || (echo "Snowflake CLI is not installed. Please install it from https://docs.snowflake.com/en/user-guide/snowsql-install-config.html" && exit 1) - @which localstack > /dev/null 2>&1 || (echo "LocalStack is not installed. Please install it from https://docs.localstack.cloud/getting-started/installation/" && exit 1) + @which lstk > /dev/null 2>&1 || (echo "lstk is not installed. Please install it from https://docs.localstack.cloud/aws/developer-tools/running-localstack/lstk/" && exit 1) + @which aws > /dev/null 2>&1 || (echo "AWS CLI is not installed. Please install it from https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html" && exit 1) @echo python > /dev/null 2>&1 || (echo "Python is not installed. Please install it from https://www.python.org/downloads/" && exit 1) @echo virtualenv > /dev/null 2>&1 || (echo "virtualenv is not installed. Please install it from https://virtualenv.pypa.io/en/latest/installation.html" && exit 1) @echo docker > /dev/null 2>&1 || (echo "Docker is not installed. Please install it from https://docs.docker.com/get-docker/" && exit 1) @@ -89,13 +90,13 @@ debug: ## Clean up everything and redeploy to fix bugs snow sql -c localstack -q "USE DATABASE FACTORY_PIPELINE_DEMO; USE SCHEMA PUBLIC; DROP FILE FORMAT IF EXISTS csv_format;" snow sql -c localstack -q "DROP PIPE IF EXISTS FACTORY_PIPELINE_DEMO.PUBLIC.SENSOR_DATA_PIPE;" snow sql -c localstack -q "DROP TABLE IF EXISTS FACTORY_PIPELINE_DEMO.PUBLIC_RAW.SENSOR_DATA;" - awslocal s3 rb s3://factory-sensor-data-local --force + lstk aws s3 rb s3://factory-sensor-data-local --force make deploy @echo "Debug cleanup and redeploy completed successfully." alerts: ## Setup alerts @echo "Setting up alerts..." - awslocal ses verify-email-identity --email hello@example.com + lstk aws ses verify-email-identity --email hello@example.com snow sql -f solutions/task_alert_udf.sql -c localstack @echo "Alerts setup successfully." @@ -110,23 +111,17 @@ test: ## Run tests start: ## Start LocalStack @echo "Starting LocalStack..." @test -n "${LOCALSTACK_AUTH_TOKEN}" || (echo "LOCALSTACK_AUTH_TOKEN is not set. Find your token at https://app.localstack.cloud/workspace/auth-token"; exit 1) - DOCKER_FLAGS='-e SF_LOG=trace' \ - DEBUG=1 \ - IMAGE_NAME=localstack/snowflake:latest \ LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) \ - localstack start -d + lstk start @echo "LocalStack started successfully." stop: ## Stop LocalStack @echo "Stopping LocalStack..." - @localstack stop + @lstk stop @echo "LocalStack stopped successfully." -ready: ## Make sure the LocalStack container is up - @echo Waiting on the LocalStack container... - @localstack wait -t 30 && echo LocalStack is ready to use! || (echo Gave up waiting on LocalStack, exiting. && exit 1) logs: ## Save the logs in a separate file - @localstack logs > logs.txt + @lstk logs > logs.txt -.PHONY: install seed aws upload pipeline dbt app deploy test start stop ready logs debug generate +.PHONY: install seed aws upload pipeline dbt app deploy test start stop logs debug generate diff --git a/README.md b/README.md index 6504dde..85d9518 100644 --- a/README.md +++ b/README.md @@ -24,10 +24,9 @@ The application implements a modern data pipeline architecture showcasing a real ## Prerequisites -- A valid [LocalStack for Snowflake license](https://localstack.cloud/pricing). Your license provides a [`LOCALSTACK_AUTH_TOKEN`](https://docs.localstack.cloud/getting-started/auth-token/) to activate LocalStack. +- A valid [LocalStack for Snowflake license](https://localstack.cloud/pricing). Your license provides a [`LOCALSTACK_AUTH_TOKEN`](https://docs.localstack.cloud/aws/getting-started/auth-token/) to activate LocalStack. - [Docker](https://docs.docker.com/get-docker/) -- [`localstack` CLI](https://docs.localstack.cloud/getting-started/installation/#localstack-cli). -- [AWS CLI](https://docs.localstack.cloud/user-guide/integrations/aws-cli/) with the [`awslocal` wrapper](https://docs.localstack.cloud/user-guide/integrations/aws-cli/#localstack-aws-cli-awslocal). +- [`lstk` CLI](https://docs.localstack.cloud/aws/developer-tools/running-localstack/lstk/). The [AWS CLI](https://docs.localstack.cloud/user-guide/integrations/aws-cli/) is required by `lstk aws`. - [Snowflake CLI](https://docs.snowflake.com/developer-guide/snowflake-cli/index) with a [`localstack` connection profile](https://snowflake.localstack.cloud/user-guide/integrations/snow-cli/). - [Python](https://www.python.org/downloads/) 3.10+ & [`pip`](https://pip.pypa.io/en/stable/installation/) - [`make`](https://www.gnu.org/software/make/) (**optional**, but recommended for running the sample application) @@ -59,11 +58,8 @@ make install Start LocalStack with the `LOCALSTACK_AUTH_TOKEN` pre-configured: ```bash -localstack auth set-token -DOCKER_FLAGS='-e SF_LOG=trace' \ -DEBUG=1 \ -IMAGE_NAME=localstack/snowflake:latest \ -localstack start +export LOCALSTACK_AUTH_TOKEN= +lstk start ``` To deploy the sample application, run the following command: @@ -186,14 +182,14 @@ Cloud Pods enable persistent state snapshots of your LocalStack instance that ca To save a Cloud Pod, run the following command: ```bash -localstack pod save smart-factory-app +lstk snapshot save pod:smart-factory-app ``` To load a Cloud Pod, run the following command: ```bash # Restore the saved state in a fresh LocalStack instance -localstack pod load smart-factory-app +lstk snapshot load pod:smart-factory-app ``` The key advantages are: From 7b9e15c9b11546d12985d40a741d1c5cdc1789c7 Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Fri, 4 Sep 2026 18:54:46 +0530 Subject: [PATCH 2/2] Create warehouse TEST in the seed script; the emulator no longer auto-creates it --- setup/01_setup_snowflake.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup/01_setup_snowflake.sql b/setup/01_setup_snowflake.sql index ac71ae1..227fad7 100644 --- a/setup/01_setup_snowflake.sql +++ b/setup/01_setup_snowflake.sql @@ -1,3 +1,6 @@ +-- Create the warehouse the connection profile references +CREATE WAREHOUSE IF NOT EXISTS TEST; + -- Create and use database CREATE DATABASE IF NOT EXISTS FACTORY_PIPELINE_DEMO; USE DATABASE FACTORY_PIPELINE_DEMO;