From 20802fe90dcc1e75f8ada787c3201e448349eef7 Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Fri, 4 Sep 2026 17:27:53 +0530 Subject: [PATCH 1/2] Migrate from the localstack CLI to lstk --- .github/workflows/main.yml | 19 +++++++------------ Makefile | 16 +++++----------- README.md | 15 +++++++-------- deploy.sh | 10 +++++----- 4 files changed, 24 insertions(+), 36 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bdecca1..d9572ec 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,10 +37,10 @@ jobs: with: use-installer: true - - name: Setup SAM-Local + - name: Install lstk run: | - pip install aws-sam-cli-local - samlocal --help + npm install -g @localstack/lstk + sam --version - name: Install yq run: | @@ -60,15 +60,10 @@ jobs: - name: Start LocalStack env: LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} - DNS_ADDRESS: 0 + LOCALSTACK_DNS_ADDRESS: 0 run: | docker pull localstack/localstack-pro:latest - # Start LocalStack in the background - LS_LOG=trace LOCALSTACK_AUTH_TOKEN=$LOCALSTACK_AUTH_TOKEN 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 - echo "Startup complete" + LOCALSTACK_LS_LOG=trace lstk start - name: Deploy the application run: | @@ -77,12 +72,12 @@ jobs: - name: Check deployed resources run: | sleep 20 - samlocal list stack-outputs --stack-name sam-app --region us-east-1 --output json + lstk sam list stack-outputs --stack-name sam-app --region us-east-1 --output json - name: Run integration tests run: | set -euo pipefail - api_id=$(samlocal list stack-outputs --stack-name sam-app --region us-east-1 --output json \ + api_id=$(lstk sam list stack-outputs --stack-name sam-app --region us-east-1 --output json \ | jq -r '.[] | select(.OutputKey=="ApiBasePath") | .OutputValue' \ | sed -E 's#https?://##; s#\..*##') base="https://${api_id}.execute-api.localhost.localstack.cloud:4566" diff --git a/Makefile b/Makefile index 939969d..934e820 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,7 @@ usage: ## Install dependencies install: - @which localstack || pip install localstack - @which samlocal || pip install aws-sam-cli-local + @which lstk || npm install -g @localstack/lstk @which artillery || npm install -g artillery@latest pip install -r requirements.txt @@ -21,20 +20,15 @@ deploy: ## Start LocalStack in detached mode start: @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 ## Stop the Running LocalStack container stop: @echo - localstack stop - -## Make sure the LocalStack container is up -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 stop ## Save the logs in a separate file, since the LS container will only contain the logs of the last sample run. logs: - @localstack logs > logs.txt + @lstk logs > logs.txt -.PHONY: usage install deploy start stop ready logs +.PHONY: usage install deploy start stop logs diff --git a/README.md b/README.md index 0cfa922..144a932 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,9 @@ We are using the following AWS services to build our infrastructure: ## 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). -* [Serverless Application Model](https://docs.localstack.cloud/user-guide/integrations/aws-sam/) with the [samlocal](https://github.com/localstack/aws-sam-cli-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/), installed via `npm install -g @localstack/lstk` or `brew install localstack/tap/lstk`. +* [Serverless Application Model](https://docs.localstack.cloud/user-guide/integrations/aws-sam/), used via the `lstk sam` proxy. * [Python 3.9 installed](https://www.python.org/downloads/). * [Node.js](https://nodejs.org/en/download) with npm package manager. * [Artillery](https://artillery.io/docs/guides/overview/welcome.html) to generate some load towards both the apis. @@ -47,7 +47,6 @@ Start LocalStack with the `LOCALSTACK_AUTH_TOKEN` pre-configured: ```shell export LOCALSTACK_AUTH_TOKEN= make start -make ready ``` ## Instructions @@ -63,16 +62,16 @@ Alternatively, here are instructions to deploy it manually step-by-step. This stack facilitates the seamless provisioning of an RDS Aurora PostgreSQL database, accompanied by an RDS Proxy to serve as its front-end. The entire setup will be securely deployed within a VPC, utilizing three private subnets. The essential parameters required for the [next step](#deploy-serverless-workload-using-rds-aurora-as-backend) are also provided as stack outputs, ensuring a smooth continuation of the deployment process. ```bash -samlocal build -t rds-with-proxy.yaml --use-container -samlocal deploy -t rds-with-proxy.yaml --guided +lstk sam build -t rds-with-proxy.yaml --use-container +lstk sam deploy -t rds-with-proxy.yaml --guided ``` ### Deploy serverless workload using RDS Aurora as backend To initiate the initial build and deployment of your application, execute the following command in your shell: ```bash -samlocal build --use-container -samlocal deploy --guided +lstk sam build --use-container +lstk sam deploy --guided ``` ### Create a user with `rds_iam` role diff --git a/deploy.sh b/deploy.sh index 579836e..2c7b73f 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,11 +1,11 @@ -samlocal deploy -t rds-with-proxy.yaml\ +lstk sam deploy -t rds-with-proxy.yaml\ --stack-name sam-infra \ --region us-east-1 \ --capabilities CAPABILITY_IAM \ --no-fail-on-empty-changeset \ --no-confirm-changeset -samlocal list stack-outputs \ +lstk sam list stack-outputs \ --stack-name sam-infra \ --region us-east-1 \ --output json > output-infra.json @@ -19,8 +19,8 @@ database_port=$(jq -r '.[] | select(.OutputKey=="databasePort") | .OutputValue' secret_arn=$(jq -r '.[] | select(.OutputKey=="secretArn") | .OutputValue' output-infra.json) lambda_sg_group_id=$(jq -r '.[] | select(.OutputKey=="lambdaSgGroupId") | .OutputValue' output-infra.json) -samlocal build --use-container -samlocal deploy \ +lstk sam build --use-container +lstk sam deploy \ --stack-name sam-app \ --region us-east-1 \ --capabilities CAPABILITY_IAM \ @@ -38,7 +38,7 @@ samlocal deploy \ CreateFunctionSecurityGroup=True \ LambdaSecurityGroupId=$lambda_sg_group_id -samlocal list stack-outputs \ +lstk sam list stack-outputs \ --stack-name sam-app \ --region us-east-1 \ --output json > output-app.json From 618456c7256f19b1abd77109294485477ee1493f Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Fri, 4 Sep 2026 17:32:59 +0530 Subject: [PATCH 2/2] Declare boto3 in requirements; it was installed transitively by the legacy CLI --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 810ba6c..7ed4a53 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -psycopg2-binary \ No newline at end of file +psycopg2-binary +boto3