From a3d5a8139d3a5e371f5e7774dc3dccb95b263da1 Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Tue, 18 Aug 2026 19:23:51 +0530 Subject: [PATCH 1/4] Migrate from the localstack CLI to lstk --- .github/workflows/main.yml | 19 ++++++------------- Makefile | 14 ++++++-------- README.md | 14 +++++++------- 3 files changed, 19 insertions(+), 28 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 09bef22..0c390bc 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 Node.js uses: actions/setup-node@v4 with: @@ -34,8 +32,8 @@ jobs: - name: Install CDK run: | - npm install -g aws-cdk-local aws-cdk - cdklocal --version + npm install -g @localstack/lstk aws-cdk + cdk --version - name: Setup .NET Core uses: actions/setup-dotnet@v3 @@ -55,15 +53,10 @@ jobs: - name: Start LocalStack env: LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} - DNS_ADDRESS: 0 + LOCALSTACK_DNS_ADDRESS: 0 run: | - pip install localstack awscli-local[ver1] docker pull localstack/localstack:latest - # Start LocalStack in the background - LS_LOG=trace localstack start -d - # Wait 30 seconds for the LocalStack container to become ready before timing out - echo "Waiting for LocalStack startup..." - localstack wait -t 15 + LOCALSTACK_LS_LOG=trace lstk start --non-interactive echo "Startup complete" - name: Deploy infrastructure using CDK @@ -75,8 +68,8 @@ jobs: run: | cd cdk-user-microservice/src/CdkUserMicroservice && dotnet build cd ../.. - cdklocal bootstrap - cdklocal deploy --require-approval never + lstk cdk bootstrap + lstk cdk deploy --require-approval never - name: Send a Slack notification if: failure() || github.event_name != 'pull_request' diff --git a/Makefile b/Makefile index 74bfe4c..8ea84be 100644 --- a/Makefile +++ b/Makefile @@ -7,26 +7,24 @@ 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 cdklocal || npm install -g aws-cdk-local aws-cdk + @which lstk || npm install -g @localstack/lstk aws-cdk start: ## Start 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) - @LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) localstack start -d + @LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) lstk start --non-interactive stop: ## Stop LocalStack - @localstack stop + @lstk stop 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: ## Deploy infrastructure using CDK cd cdk-user-microservice/src/CdkUserMicroservice && dotnet build - cd cdk-user-microservice && cdklocal bootstrap && cdklocal deploy --require-approval never + cd cdk-user-microservice && lstk cdk bootstrap && lstk cdk deploy --require-approval never .PHONY: usage install start stop ready logs deploy diff --git a/README.md b/README.md index 4ebe3a8..b498d2f 100644 --- a/README.md +++ b/README.md @@ -31,9 +31,9 @@ We are using the following AWS services and their features to build our infrastr ## Prerequisites -- 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. -- [`localstack` CLI](https://docs.localstack.cloud/getting-started/installation/#localstack-cli). -- [Cloud Development Kit](https://docs.localstack.cloud/user-guide/integrations/aws-cdk/) with the [`cdklocal`](https://www.npmjs.com/package/aws-cdk-local) installed. +- 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. +- [`lstk` CLI](https://docs.localstack.cloud/aws/developer-tools/running-localstack/lstk/). +- [Cloud Development Kit](https://docs.localstack.cloud/user-guide/integrations/aws-cdk/) installed, deployed via the `lstk cdk` proxy. - [.NET Core 7.0](https://dotnet.microsoft.com/en-us/download/dotnet/7.0) or later and [.NET Core Global Tools for AWS](https://aws.amazon.com/blogs/developer/net-core-global-tools-for-aws/) ## Start LocalStack @@ -46,7 +46,7 @@ make start make ready ``` -We specified DEBUG=1 to get the printed LocalStack logs directly in the terminal to help us visualize the background tasks in action. If you prefer running LocalStack in detached mode, you can add the `-d` flag to the `localstack start` command, and use Docker Desktop to view the logs. +We specified DEBUG=1 to get the printed LocalStack logs directly in the terminal to help us visualize the background tasks in action. If you prefer running LocalStack in detached mode, you can add the `--non-interactive` flag to the `lstk start` command, and use Docker Desktop to view the logs. ## Instructions @@ -64,13 +64,13 @@ cd ../../.. ### Deploying the CDK code -To create the AWS infrastructure locally, you can use CDK and `cdklocal` wrapper. To deploy the infrastructure, you can run the following commands: +To create the AWS infrastructure locally, you can use CDK and the `lstk cdk` proxy. To deploy the infrastructure, you can run the following commands: ```bash cd cdk-user-microservice/src/CdkUserMicroservice && dotnet build cd ../.. -cdklocal bootstrap -cdklocal deploy +lstk cdk bootstrap +lstk cdk deploy ``` This will deploy the `CdkUserMicroserviceStack` stack on LocalStack. You will see the following output: From 52c4bbf75ba56828449fa84061c2018488d02486 Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Fri, 4 Sep 2026 15:47:13 +0530 Subject: [PATCH 2/4] Address review feedback: restore keep-alive via API, drop the ready target --- .github/workflows/main.yml | 9 ++++++++- Makefile | 6 +----- README.md | 3 +-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0c390bc..a682567 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,6 +16,7 @@ on: permissions: contents: write + actions: write jobs: cdk: @@ -57,7 +58,6 @@ jobs: run: | docker pull localstack/localstack:latest LOCALSTACK_LS_LOG=trace lstk start --non-interactive - echo "Startup complete" - name: Deploy infrastructure using CDK env: @@ -95,3 +95,10 @@ jobs: with: name: diagnose.json.gz path: ./diagnose.json.gz + + # 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 8ea84be..358f899 100644 --- a/Makefile +++ b/Makefile @@ -16,10 +16,6 @@ start: ## Start LocalStack stop: ## Stop LocalStack @lstk stop -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 @@ -27,4 +23,4 @@ deploy: ## Deploy infrastructure using CDK cd cdk-user-microservice/src/CdkUserMicroservice && dotnet build cd cdk-user-microservice && lstk cdk bootstrap && lstk cdk deploy --require-approval never -.PHONY: usage install start stop ready logs deploy +.PHONY: usage install start stop logs deploy diff --git a/README.md b/README.md index b498d2f..1436557 100644 --- a/README.md +++ b/README.md @@ -43,10 +43,9 @@ Start LocalStack with the `LOCALSTACK_AUTH_TOKEN` pre-configured: ```shell export LOCALSTACK_AUTH_TOKEN= make start -make ready ``` -We specified DEBUG=1 to get the printed LocalStack logs directly in the terminal to help us visualize the background tasks in action. If you prefer running LocalStack in detached mode, you can add the `--non-interactive` flag to the `lstk start` command, and use Docker Desktop to view the logs. +We specified DEBUG=1 to get the printed LocalStack logs directly in the terminal to help us visualize the background tasks in action. `lstk` always runs LocalStack in the background; use `lstk logs` or Docker Desktop to view the logs. ## Instructions From 7fcdcbad111a816ac795f8bfc2890b81d1e62c9d Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Fri, 4 Sep 2026 15:56:57 +0530 Subject: [PATCH 3/4] Drop --non-interactive from lstk start; lstk auto-detects non-interactive environments --- .github/workflows/main.yml | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a682567..ddb8bba 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,7 +57,7 @@ jobs: LOCALSTACK_DNS_ADDRESS: 0 run: | docker pull localstack/localstack:latest - LOCALSTACK_LS_LOG=trace lstk start --non-interactive + LOCALSTACK_LS_LOG=trace lstk start - name: Deploy infrastructure using CDK env: diff --git a/Makefile b/Makefile index 358f899..9e19cdb 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ install: ## Install dependencies start: ## Start 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) - @LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) lstk start --non-interactive + @LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) lstk start stop: ## Stop LocalStack @lstk stop From 2a087d9430bdbe2b5cadf792fe62c71ec31f69f9 Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Fri, 4 Sep 2026 16:04:37 +0530 Subject: [PATCH 4/4] Remove the workflow keep-alive step; handled by the org-wide keepalive.yml --- .github/workflows/main.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ddb8bba..f1e1634 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,6 @@ on: permissions: contents: write - actions: write jobs: cdk: @@ -95,10 +94,3 @@ jobs: with: name: diagnose.json.gz path: ./diagnose.json.gz - - # 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