From 337027a23ef626fc7003d57ece7965cfed97765e Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Tue, 18 Aug 2026 18:44:09 +0530 Subject: [PATCH 1/3] Migrate from the localstack CLI to lstk --- .github/workflows/main.yml | 7 ++----- Makefile | 11 +++++------ README.md | 12 ++++++------ run.sh | 8 ++++---- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4792b34..cba671e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,15 +43,12 @@ jobs: run: | docker pull localstack/localstack-pro:latest # Start LocalStack in the background - DEBUG=1 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 + LOCALSTACK_DEBUG=1 LOCALSTACK_AUTH_TOKEN=$LOCALSTACK_AUTH_TOKEN lstk start --non-interactive echo "Startup complete" - name: Run the application run: | - awslocal s3 mb s3://testbucket + lstk aws s3 mb s3://testbucket make run - name: Send a Slack notification diff --git a/Makefile b/Makefile index db0d158..d23475f 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,7 @@ usage: ## Show this help install: ## Install dependencies @test -e node_modules || yarn install - @which localstack || pip install localstack - @which awslocal || pip install awscli-local + @which lstk || npm install -g @localstack/lstk @test -e .venv || (python3 -m venv .venv; source .venv/bin/activate; pip install -r requirements.txt) run: ## Deploy the app locally and run an AppSync GraphQL test invocation @@ -18,17 +17,17 @@ run: ## Deploy the app locally and run an AppSync GraphQL test invocatio 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: @echo - localstack stop + lstk stop 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: - @localstack logs > logs.txt + @lstk logs > logs.txt test-ci: make start install ready run; return_code=`echo $$?`;\ diff --git a/README.md b/README.md index 5accc10..dc3ec51 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,9 @@ We are using the following AWS services and third-party integrations to build ou ## 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). -- [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). +- 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/). +- [AWS CLI](https://docs.localstack.cloud/user-guide/integrations/aws-cli/) (required by `lstk aws`). - [Python](https://www.python.org/downloads/) - [`cURL`](https://curl.se/) - [`wscat`](https://github.com/websockets/wscat) @@ -70,8 +70,8 @@ After a few seconds, the infrastructure should be deployed successfully. Fetch t ```sh export APPSYNC_URL=http://localhost:4566/graphql -api_id=$(awslocal appsync list-graphql-apis | jq -r '(.graphqlApis[] | select(.name=="test-api")).apiId') -api_key=$(awslocal appsync create-api-key --api-id $api_id | jq -r .apiKey.id) +api_id=$(lstk aws appsync list-graphql-apis | jq -r '(.graphqlApis[] | select(.name=="test-api")).apiId') +api_key=$(lstk aws appsync create-api-key --api-id $api_id | jq -r .apiKey.id) echo $api_key echo $api_id ``` @@ -111,7 +111,7 @@ curl -H "Content-Type: application/json" -H "x-api-key: $api_key" -d '{"query":" We can now perform a scan operation on the DynamoDB table which will include an entry with `id123` as the `id`: ```sh -awslocal dynamodb scan --table-name table1 +lstk aws dynamodb scan --table-name table1 { "Items": [ { diff --git a/run.sh b/run.sh index 7e071e1..95616b3 100755 --- a/run.sh +++ b/run.sh @@ -5,15 +5,15 @@ set -e APPSYNC_URL=http://localhost:4566/graphql # Create a new S3 bucket -awslocal s3 mb s3://testbucket +lstk aws s3 mb s3://testbucket # Deploy the Serverless app to the local environment and run the tests echo "Deploying Serverless app to local environment"; \ SLS_DEBUG=1 yarn deploy && \ echo "Serverless app successfully deployed." && \ -api_id=$(awslocal appsync list-graphql-apis | jq -r '(.graphqlApis[] | select(.name=="test-api")).apiId') && \ +api_id=$(lstk aws appsync list-graphql-apis | jq -r '(.graphqlApis[] | select(.name=="test-api")).apiId') && \ echo "DEBUG: api_id is: $api_id" && \ -api_key=$(awslocal appsync create-api-key --api-id $api_id | jq -r .apiKey.id) && \ +api_key=$(lstk aws appsync create-api-key --api-id $api_id | jq -r .apiKey.id) && \ echo "DEBUG: api_key is: $api_key" && \ echo "Starting a WebSocket client to subscribe to GraphQL mutation operations." && \ source .venv/bin/activate && \ @@ -22,7 +22,7 @@ echo "Now trying to invoke the AppSync API for DynamoDB integration under $APPSY curl -H "Content-Type: application/json" -H "x-api-key: $api_key" -d '{"query":"mutation {addPostDDB(id: \"id123\"){id}}"}' $APPSYNC_URL/$api_id && \ curl -H "Content-Type: application/json" -H "x-api-key: $api_key" -d '{"query":"query {getPostsDDB{id}}"}' $APPSYNC_URL/$api_id && \ echo "Scanning items from DynamoDB table - should include entry with 'id123':" && \ -result_ddb_scan=$(awslocal dynamodb scan --table-name table1) && \ +result_ddb_scan=$(lstk aws dynamodb scan --table-name table1) && \ echo $result_ddb_scan | jq -r . && \ echo "Now trying to invoke the AppSync API for RDS integration." && \ curl -H "Content-Type: application/json" -H "x-api-key: $api_key" -d '{"query":"mutation {addPostRDS(id: \"id123\"){id}}"}' $APPSYNC_URL/$api_id && \ From 99c5937771f6f0265eb2c44ccfa8854e861c08dc Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Tue, 18 Aug 2026 18:49:51 +0530 Subject: [PATCH 2/3] Run lstk setup aws before using lstk aws in CI --- .github/workflows/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cba671e..39fffb3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,6 +46,9 @@ jobs: LOCALSTACK_DEBUG=1 LOCALSTACK_AUTH_TOKEN=$LOCALSTACK_AUTH_TOKEN lstk start --non-interactive echo "Startup complete" + - name: Set up the AWS profile for lstk aws + run: lstk setup aws + - name: Run the application run: | lstk aws s3 mb s3://testbucket From deda9f36d2dc3704f998e98606f6c86ab21db9a4 Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Tue, 18 Aug 2026 18:53:31 +0530 Subject: [PATCH 3/3] Enable the RDS Data API HTTP endpoint required by the AppSync resolver --- serverless.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/serverless.yml b/serverless.yml index 3664e23..e163329 100644 --- a/serverless.yml +++ b/serverless.yml @@ -27,6 +27,7 @@ resources: DBClusterIdentifier: ${self:custom.rds.dbcluster} MasterUsername: ${self:custom.rds.username} MasterUserPassword: ${self:custom.rds.password} + EnableHttpEndpoint: true RDSDatabaseSecret: Type: AWS::SecretsManager::Secret Properties: