From c013484832dd9dfcdf62e2c7dab27720488fae29 Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Tue, 18 Aug 2026 19:24:27 +0530 Subject: [PATCH 1/4] Migrate from the localstack CLI to lstk --- .github/workflows/main.yml | 21 ++++++++------------- Makefile | 14 +++++++------- README.md | 18 +++++++++--------- docker-compose.yml | 2 +- 4 files changed, 25 insertions(+), 30 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5850b5b..1feb109 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,8 +25,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - uses: gautamkrishnar/keepalive-workflow@v1 - - name: Setup Python uses: actions/setup-python@v4 with: @@ -42,20 +40,17 @@ jobs: with: use-installer: true - - name: Setup SAM-Local - run: | - pip install aws-sam-cli-local - samlocal --help + - name: Install lstk + run: npm install -g @localstack/lstk - name: Start LocalStack run: | - pip install localstack docker pull localstack/localstack-pro:latest # Start LocalStack in the background - DEBUG=1 localstack start -d - # Wait 30 seconds for the LocalStack container to become ready before timing out + LOCALSTACK_DEBUG=1 lstk start --non-interactive + # Wait for the LocalStack container to become ready before timing out echo "Waiting for LocalStack startup..." - localstack wait -t 15 + lstk status echo "Startup complete" env: LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} @@ -65,12 +60,12 @@ jobs: cd function pip install --target ../package/python -r requirements.txt - - name: Build the SAM app + - name: Build the SAM app run: | - samlocal build + lstk sam build - name: Deploy the SAM app run: | curl http://localhost:4566/_localstack/info - samlocal deploy --no-confirm-changeset + lstk sam deploy --no-confirm-changeset \ No newline at end of file diff --git a/Makefile b/Makefile index e336079..7449b86 100644 --- a/Makefile +++ b/Makefile @@ -7,9 +7,9 @@ usage: ## Show this help @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' install: ## Install dependencies - @which localstack || pip install localstack - @which awslocal || pip install awscli-local - @which samlocal || pip install aws-sam-cli-local + @which lstk || npm install -g @localstack/lstk + @which aws || pip install awscli + @which sam || pip install aws-sam-cli start: ## Start LocalStack and Neo4j using Docker Compose @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) @@ -20,14 +20,14 @@ stop: ## Stop LocalStack and Neo4j ready: ## Wait until LocalStack is ready @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) + @lstk status && 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 deploy: ## Build and deploy the SAM application cd function && pip install --target ../package/python -r requirements.txt - samlocal build - samlocal deploy --no-confirm-changeset + lstk sam build + lstk sam deploy --no-confirm-changeset .PHONY: usage install start stop ready logs deploy diff --git a/README.md b/README.md index 433d41f..8572202 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,12 @@ This sample application will guide you through the process of integrating a loca ## Prerequisites -- LocalStack with the [`localstack` CLI](https://docs.localstack.cloud/getting-started/installation/#localstack-cli). -- [Serverless Application Model](https://docs.localstack.cloud/user-guide/integrations/aws-sam/) with the [`samlocal`](https://github.com/localstack/aws-sam-cli-local) installed. -- [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). +- LocalStack with the [`lstk` CLI](https://docs.localstack.cloud/aws/developer-tools/running-localstack/lstk/). +- [Serverless Application Model](https://docs.localstack.cloud/user-guide/integrations/aws-sam/) with `aws-sam-cli` installed, used via the `lstk sam` proxy. +- [AWS CLI](https://docs.localstack.cloud/user-guide/integrations/aws-cli/), required by `lstk aws`. - [Python 3.10](https://www.python.org/downloads/) & `pip` - [Docker Compose](https://docs.docker.com/compose/install/) -- A valid [LocalStack for AWS 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 AWS license](https://localstack.cloud/pricing). Your license provides a [`LOCALSTACK_AUTH_TOKEN`](https://docs.localstack.cloud/aws/getting-started/auth-token/) to activate LocalStack. Start LocalStack Pro with the `LOCALSTACK_AUTH_TOKEN` pre-configured: @@ -48,7 +48,7 @@ pip install --target ../package/python -r requirements.txt To build the SAM application, run the following command from the root directory of the application: ```shell -samlocal build +lstk sam build ``` If you see a `Build Succeeded` message, you can proceed to the next step. @@ -59,7 +59,7 @@ If you see a `Build Succeeded` message, you can proceed to the next step. To deploy the SAM application, run the following command: ```shell -samlocal deploy --guided +lstk sam deploy --guided ``` The above command will create a new managed S3 bucket to store the artifacts of the SAM application. If you want to use an existing S3 bucket, you can use the `--s3-bucket` flag to specify the bucket name. Before being deployed, the CloudFormation changeset will be displayed in the terminal. If you want to deploy the application without confirmation, you can use the `--no-confirm-changeset` flag. @@ -72,8 +72,8 @@ You need to update the Lambda function configuration to use the Neo4j environmen export NEO4J_PASSWORD=neo4j-harsh-test export NEO4J_URI=bolt://neo4j:7687 export NEO4J_USERNAME=neo4j -FUNCTION=$(awslocal cloudformation describe-stack-resource --stack-name sam-app --logical-resource-id function --query 'StackResourceDetail.PhysicalResourceId' --output text) -awslocal lambda update-function-configuration \ +FUNCTION=$(lstk aws cloudformation describe-stack-resource --stack-name sam-app --logical-resource-id function --query 'StackResourceDetail.PhysicalResourceId' --output text) +lstk aws lambda update-function-configuration \ --function-name $FUNCTION \ --environment "Variables={NEO4J_USERNAME=$NEO4J_USERNAME,NEO4J_PASSWORD=$NEO4J_PASSWORD,NEO4J_URI=$NEO4J_URI}" ``` @@ -83,7 +83,7 @@ awslocal lambda update-function-configuration \ You can invoke the Lambda function using the following command: ```shell -awslocal lambda invoke \ +lstk aws lambda invoke \ --function-name $FUNCTION \ --payload file://event.json \ --cli-binary-format raw-in-base64-out out.json diff --git a/docker-compose.yml b/docker-compose.yml index 40a6cec..4a42521 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.9' services: localstack: - container_name: "${LOCALSTACK_DOCKER_NAME:-localstack-main}" + container_name: "${LOCALSTACK_DOCKER_NAME:-localstack-aws}" image: localstack/localstack-pro:latest # required for Pro ports: - "127.0.0.1:4566:4566" # LocalStack Gateway From ab6828bb47ef173ebb18f50a885b2b9be5aa6708 Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Fri, 4 Sep 2026 15:47:02 +0530 Subject: [PATCH 2/4] Address review feedback: restore keep-alive via API, drop wait steps --- .github/workflows/main.yml | 13 ++++++++----- Makefile | 6 +----- README.md | 1 - 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1feb109..e3b9911 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,6 +16,7 @@ on: permissions: contents: write + actions: write jobs: sam: @@ -48,10 +49,6 @@ jobs: docker pull localstack/localstack-pro:latest # Start LocalStack in the background LOCALSTACK_DEBUG=1 lstk start --non-interactive - # Wait for the LocalStack container to become ready before timing out - echo "Waiting for LocalStack startup..." - lstk status - echo "Startup complete" env: LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} @@ -68,4 +65,10 @@ jobs: run: | curl http://localhost:4566/_localstack/info lstk sam deploy --no-confirm-changeset - \ No newline at end of file + + # Re-enabling the workflow resets GitHub's 60-day scheduled-workflow inactivity timer + - name: Keep the scheduled workflow enabled + if: always() + env: + GH_TOKEN: ${{ github.token }} + run: gh api -X PUT repos/${{ github.repository }}/actions/workflows/main.yml/enable diff --git a/Makefile b/Makefile index 7449b86..4ee46a0 100644 --- a/Makefile +++ b/Makefile @@ -18,10 +18,6 @@ start: ## Start LocalStack and Neo4j using Docker Compose stop: ## Stop LocalStack and Neo4j @docker-compose down -ready: ## Wait until LocalStack is ready - @echo Waiting on the LocalStack container... - @lstk status && echo LocalStack is ready to use! || (echo Gave up waiting on LocalStack, exiting. && exit 1) - logs: ## Save the logs in a separate file @lstk logs > logs.txt @@ -30,4 +26,4 @@ deploy: ## Build and deploy the SAM application lstk sam build lstk sam deploy --no-confirm-changeset -.PHONY: usage install start stop ready logs deploy +.PHONY: usage install start stop logs deploy diff --git a/README.md b/README.md index 8572202..15da249 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,6 @@ Start LocalStack Pro with the `LOCALSTACK_AUTH_TOKEN` pre-configured: ```shell export LOCALSTACK_AUTH_TOKEN= make start -make ready ``` The Docker Compose file will start LocalStack Pro and a local Neo4j database. The `LOCALSTACK_AUTH_TOKEN` environment variable is required to activate the LocalStack Pro features, such as Lambda Layers in this example. From aa31244245c7cd36be078dea6a3f74894c290342 Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Fri, 4 Sep 2026 15:56:11 +0530 Subject: [PATCH 3/4] Drop --non-interactive from lstk start; lstk auto-detects non-interactive environments --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e3b9911..33caf7e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,7 +48,7 @@ jobs: run: | docker pull localstack/localstack-pro:latest # Start LocalStack in the background - LOCALSTACK_DEBUG=1 lstk start --non-interactive + LOCALSTACK_DEBUG=1 lstk start env: LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} From 63b7efe2dceb86dbc7321005047a4ca7c776ffdf Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Fri, 4 Sep 2026 16:02:13 +0530 Subject: [PATCH 4/4] Update main.yml --- .github/workflows/main.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 33caf7e..8fdf6bd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -65,10 +65,3 @@ jobs: run: | curl http://localhost:4566/_localstack/info lstk sam deploy --no-confirm-changeset - - # Re-enabling the workflow resets GitHub's 60-day scheduled-workflow inactivity timer - - name: Keep the scheduled workflow enabled - if: always() - env: - GH_TOKEN: ${{ github.token }} - run: gh api -X PUT repos/${{ github.repository }}/actions/workflows/main.yml/enable