From ce1da678c4140a2c1c0dfaacb77cebd62669539d Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Sat, 5 Sep 2026 11:21:41 +0530 Subject: [PATCH 1/2] Migrate remaining CLI usage to lstk Claude-Session: https://claude.ai/code/session_019Syt1j5eEeCGfuVCM78mom --- s3-static-website/README.md | 3 +- s3-static-website/deploy.ps1 | 35 +++++-------------- .../apigateway-appsync-integration/README.md | 2 +- .../apigateway-appsync-integration/run.sh | 2 +- sample-archive/apigateway-aws-lambda/run.sh | 2 +- .../apigateway-cognito-authorizer/run.sh | 12 +++---- .../apigateway-custom-domain/run.sh | 2 +- .../apigateway-eventbridge-integration/run.sh | 2 +- sample-archive/apigateway-lambda-proxy/run.sh | 2 +- .../apigateway-openapi-3.0-import/run.sh | 2 +- .../apigateway-rest-lambda-api-key/run.sh | 2 +- .../run.sh | 2 +- .../README.md | 2 +- .../run.sh | 2 +- .../run.sh | 2 +- .../run.sh | 2 +- sample-archive/cloudposse-msk/README.md | 2 +- .../s3-lambda-sqs-notification/README.md | 6 ++-- .../s3-lambda-sqs-notification/run.sh | 6 ++-- 19 files changed, 36 insertions(+), 54 deletions(-) diff --git a/s3-static-website/README.md b/s3-static-website/README.md index b8af1b1..e8d61bd 100644 --- a/s3-static-website/README.md +++ b/s3-static-website/README.md @@ -32,13 +32,12 @@ The `deploy.ps1` script supports the following switches: - `-Deploy`: Creates a bucket, sets a bucket policy, syncs a local directory to the bucket, and sets up a website on the bucket. - `-Start`: Starts LocalStack in detached mode. - `-Stop`: Stops LocalStack. -- `-Ready`: Waits for LocalStack to be ready for use. - `-Logs`: Writes LocalStack logs to a text file. For example, to install dependencies and start LocalStack, you would run: ```powershell -.\deploy.ps1 -InstallDependencies -Start -Ready -Deploy +.\deploy.ps1 -InstallDependencies -Start -Deploy ``` ### Makefile diff --git a/s3-static-website/deploy.ps1 b/s3-static-website/deploy.ps1 index 05d843e..f56b0fa 100644 --- a/s3-static-website/deploy.ps1 +++ b/s3-static-website/deploy.ps1 @@ -1,12 +1,11 @@ # This script is used to deploy the static website to LocalStack S3 bucket. -# It uses the LocalStack CLI to start the LocalStack container, wait for it to be ready, create an S3 bucket, upload the website files to the bucket, and configure the bucket as a static website. +# It uses the lstk CLI to start the LocalStack container, create an S3 bucket, upload the website files to the bucket, and configure the bucket as a static website. param( [switch]$InstallDependencies, [switch]$Deploy, [switch]$Start, [switch]$Stop, - [switch]$Ready, [switch]$Logs ) @@ -20,34 +19,18 @@ function Deploy-Website { [switch]$Deploy, [switch]$Start, [switch]$Stop, - [switch]$Ready, - [switch]$Logs + [switch]$Logs ) if ($InstallDependencies) { - if (-not (Get-Command -Name 'localstack' -ErrorAction SilentlyContinue)) { - pip install localstack - Write-Host "LocalStack CLI installed successfully!" - } if (-not (Get-Command -Name 'lstk' -ErrorAction SilentlyContinue)) { - pip install awscli-local - Write-Host "AWS CLI installed successfully!" + npm install -g @localstack/lstk + Write-Host "lstk CLI installed successfully!" } } if ($Start) { - localstack start -d - } - - if ($Ready) { - Write-Host "Waiting on the LocalStack container..." - localstack wait -t 30 - if ($?) { - Write-Host "Localstack is ready to use!" - } else { - Write-Host "Gave up waiting on LocalStack, exiting." - exit 1 - } + lstk start } if ($Deploy) { @@ -59,15 +42,15 @@ function Deploy-Website { } if ($Stop) { - localstack stop + lstk stop } if ($Logs){ - localstack logs > logs.txt + lstk logs > logs.txt } } # You can just run all the tasks in one go by calling the function with all the switches set to $true. -# .\deploy.ps1 -InstallDependencies -Start -Ready -Deploy -Logs -Stop -Deploy-Website -InstallDependencies:$InstallDependencies -Deploy:$Deploy -Start:$Start -Stop:$Stop -Ready:$Ready -Logs:$Logs +# .\deploy.ps1 -InstallDependencies -Start -Deploy -Logs -Stop +Deploy-Website -InstallDependencies:$InstallDependencies -Deploy:$Deploy -Start:$Start -Stop:$Stop -Logs:$Logs diff --git a/sample-archive/apigateway-appsync-integration/README.md b/sample-archive/apigateway-appsync-integration/README.md index 9a61328..cd9d011 100644 --- a/sample-archive/apigateway-appsync-integration/README.md +++ b/sample-archive/apigateway-appsync-integration/README.md @@ -17,7 +17,7 @@ More about it [here](https://docs.localstack.cloud/user-guide/aws/appsync/#graph Start LocalStack with a specific endpoint configuration: ```bash -GRAPHQL_ENDPOINT_STRATEGY=domain localstack start +LOCALSTACK_GRAPHQL_ENDPOINT_STRATEGY=domain lstk start ``` ```bash diff --git a/sample-archive/apigateway-appsync-integration/run.sh b/sample-archive/apigateway-appsync-integration/run.sh index 9213b7e..7a12236 100755 --- a/sample-archive/apigateway-appsync-integration/run.sh +++ b/sample-archive/apigateway-appsync-integration/run.sh @@ -4,7 +4,7 @@ set -euo pipefail set -x rm terraform.tfstate* || true -tflocal init; tflocal apply --auto-approve +lstk tf init; lstk tf apply --auto-approve restapi=$(aws apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r .items[0].id) curl -X POST "http://$restapi.execute-api.us-east-1.localhost.localstack.cloud:4566/dev/graphql" diff --git a/sample-archive/apigateway-aws-lambda/run.sh b/sample-archive/apigateway-aws-lambda/run.sh index f423e6f..d52c3c5 100755 --- a/sample-archive/apigateway-aws-lambda/run.sh +++ b/sample-archive/apigateway-aws-lambda/run.sh @@ -2,7 +2,7 @@ set -x -tflocal init; tflocal plan; tflocal apply --auto-approve +lstk tf init; lstk tf plan; lstk tf apply --auto-approve restapi=$(aws apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r .items[0].id) diff --git a/sample-archive/apigateway-cognito-authorizer/run.sh b/sample-archive/apigateway-cognito-authorizer/run.sh index 2c72e05..586bb93 100755 --- a/sample-archive/apigateway-cognito-authorizer/run.sh +++ b/sample-archive/apigateway-cognito-authorizer/run.sh @@ -2,17 +2,17 @@ set -x -tflocal init; tflocal plan; tflocal apply --auto-approve +lstk tf init; lstk tf plan; lstk tf apply --auto-approve -client_id=$(tflocal output -json | jq -r .user_pool_client_id.value) -pool_id=$(tflocal output -json | jq -r .user_pool_id.value) +client_id=$(lstk tf output -json | jq -r .user_pool_client_id.value) +pool_id=$(lstk tf output -json | jq -r .user_pool_id.value) sleep 5 -secret=$(awslocal cognito-idp --endpoint-url=http://localhost:4566 describe-user-pool-client --user-pool-id $pool_id --client-id $client_id | jq -r .UserPoolClient.ClientSecret) +secret=$(lstk aws cognito-idp --endpoint-url=http://localhost:4566 describe-user-pool-client --user-pool-id $pool_id --client-id $client_id | jq -r .UserPoolClient.ClientSecret) hash=$(python secret_hash.py test@localstack.com $client_id $secret) -access_token=$(awslocal cognito-idp initiate-auth --auth-flow USER_PASSWORD_AUTH --client-id $client_id --auth-parameters USERNAME="test@localstack.com",PASSWORD="L0c4lst4ck!",SECRET_HASH=$hash | jq -r .AuthenticationResult.AccessToken) +access_token=$(lstk aws cognito-idp initiate-auth --auth-flow USER_PASSWORD_AUTH --client-id $client_id --auth-parameters USERNAME="test@localstack.com",PASSWORD="L0c4lst4ck!",SECRET_HASH=$hash | jq -r .AuthenticationResult.AccessToken) -restapi=$(awslocal apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r .items[0].id) +restapi=$(lstk aws apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r .items[0].id) curl $restapi.execute-api.localhost.localstack.cloud:4566/local/demo -H "X-Auth-Token: Bearer $access_token" diff --git a/sample-archive/apigateway-custom-domain/run.sh b/sample-archive/apigateway-custom-domain/run.sh index 03e4821..2f66ad5 100755 --- a/sample-archive/apigateway-custom-domain/run.sh +++ b/sample-archive/apigateway-custom-domain/run.sh @@ -2,7 +2,7 @@ set -x -tflocal init; tflocal plan; tflocal apply --auto-approve +lstk tf init; lstk tf plan; lstk tf apply --auto-approve restapi=$(aws apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r .items[0].id) curl $restapi.execute-api.localhost.localstack.cloud:4566/dev/test -H "Host: api.example.com" diff --git a/sample-archive/apigateway-eventbridge-integration/run.sh b/sample-archive/apigateway-eventbridge-integration/run.sh index ddf9100..2f6dae1 100755 --- a/sample-archive/apigateway-eventbridge-integration/run.sh +++ b/sample-archive/apigateway-eventbridge-integration/run.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -tflocal init; tflocal plan; tflocal apply -auto-approve +lstk tf init; lstk tf plan; lstk tf apply -auto-approve restapi=$(aws --endpoint-url=http://localhost:4566 apigateway get-rest-apis | jq -r .items[0].id) curl --location --request POST "$restapi.execute-api.localhost.localstack.cloud:4566/local/orders" --header 'Content-Type: application/json' \ diff --git a/sample-archive/apigateway-lambda-proxy/run.sh b/sample-archive/apigateway-lambda-proxy/run.sh index 052a07b..7992e09 100644 --- a/sample-archive/apigateway-lambda-proxy/run.sh +++ b/sample-archive/apigateway-lambda-proxy/run.sh @@ -2,7 +2,7 @@ set -x -tflocal init; tflocal plan; tflocal apply --auto-approve +lstk tf init; lstk tf plan; lstk tf apply --auto-approve restapi=$(aws apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r .items[0].id) curl -X POST $restapi.execute-api.localhost.localstack.cloud:4566/dev/1 diff --git a/sample-archive/apigateway-openapi-3.0-import/run.sh b/sample-archive/apigateway-openapi-3.0-import/run.sh index b03d2e9..3594bcf 100755 --- a/sample-archive/apigateway-openapi-3.0-import/run.sh +++ b/sample-archive/apigateway-openapi-3.0-import/run.sh @@ -2,7 +2,7 @@ set -x -tflocal init; tflocal plan; tflocal apply --auto-approve +lstk tf init; lstk tf plan; lstk tf apply --auto-approve restapi=$(aws apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r .items[0].id) curl -vvv "$restapi.execute-api.localhost.localstack.cloud:4566/dev/api/v1/user/techops+proviosion@gmail.com" -H "X-Authorization: allow" diff --git a/sample-archive/apigateway-rest-lambda-api-key/run.sh b/sample-archive/apigateway-rest-lambda-api-key/run.sh index 8ca3d18..93e8c38 100755 --- a/sample-archive/apigateway-rest-lambda-api-key/run.sh +++ b/sample-archive/apigateway-rest-lambda-api-key/run.sh @@ -3,7 +3,7 @@ export TF_LOG=trace rm terraform.tfstate* || true -tflocal init; tflocal plan; tflocal apply --auto-approve +lstk tf init; lstk tf plan; lstk tf apply --auto-approve restapi=$(aws apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r .items[0].id) apikeyid=$(aws apigateway --endpoint-url=http://localhost:4566 get-api-keys | jq .items[].id) diff --git a/sample-archive/apigateway-rest-request-response-templates/run.sh b/sample-archive/apigateway-rest-request-response-templates/run.sh index e08279a..3c1e180 100755 --- a/sample-archive/apigateway-rest-request-response-templates/run.sh +++ b/sample-archive/apigateway-rest-request-response-templates/run.sh @@ -2,7 +2,7 @@ rm terraform.tfstate || true -tflocal init; tflocal plan; tflocal apply --auto-approve +lstk tf init; lstk tf plan; lstk tf apply --auto-approve restapi=$(aws apigateway --endpoint-url=http://localhost:4566 get-rest-apis | jq -r .items[0].id) curl -v -H "Content-Type: application/json" -d "{\"httpStatus\": \"400\", \"errorMessage\": \"Test Bad request\"}" "https://$restapi.execute-api.localhost.localstack.cloud:4566/dev/products/abcd-1234/items?status=PENDING\&limit=100" diff --git a/sample-archive/apigatewayv2-http-referer-header/README.md b/sample-archive/apigatewayv2-http-referer-header/README.md index ab83fa8..4963a5a 100644 --- a/sample-archive/apigatewayv2-http-referer-header/README.md +++ b/sample-archive/apigatewayv2-http-referer-header/README.md @@ -31,7 +31,7 @@ Both routes do the exact same thing: Return a JSON object of the form 1. Get the LocalStack API Gateway endpoint for the API: ``` - $ awslocal apigatewayv2 get-apis + $ lstk aws apigatewayv2 get-apis { "Items": [ { diff --git a/sample-archive/apigatewayv2-jwt-client-credentials-aws-proxy/run.sh b/sample-archive/apigatewayv2-jwt-client-credentials-aws-proxy/run.sh index 57ef0fc..58d6142 100755 --- a/sample-archive/apigatewayv2-jwt-client-credentials-aws-proxy/run.sh +++ b/sample-archive/apigatewayv2-jwt-client-credentials-aws-proxy/run.sh @@ -2,7 +2,7 @@ rm -rf terraform.tfstate* || true -tflocal init; tflocal plan; tflocal apply --auto-approve +lstk tf init; lstk tf plan; lstk tf apply --auto-approve secret_token=$(terraform output -raw secret_token) user_pool_client_id=$(terraform output -raw user_pool_client_id) diff --git a/sample-archive/apigatewayv2-jwt-client-credentials-http-proxy/run.sh b/sample-archive/apigatewayv2-jwt-client-credentials-http-proxy/run.sh index 57ef0fc..58d6142 100755 --- a/sample-archive/apigatewayv2-jwt-client-credentials-http-proxy/run.sh +++ b/sample-archive/apigatewayv2-jwt-client-credentials-http-proxy/run.sh @@ -2,7 +2,7 @@ rm -rf terraform.tfstate* || true -tflocal init; tflocal plan; tflocal apply --auto-approve +lstk tf init; lstk tf plan; lstk tf apply --auto-approve secret_token=$(terraform output -raw secret_token) user_pool_client_id=$(terraform output -raw user_pool_client_id) diff --git a/sample-archive/apigatewayv2-lambda-binary-custom-runtime/run.sh b/sample-archive/apigatewayv2-lambda-binary-custom-runtime/run.sh index 0b87c5f..aff680b 100755 --- a/sample-archive/apigatewayv2-lambda-binary-custom-runtime/run.sh +++ b/sample-archive/apigatewayv2-lambda-binary-custom-runtime/run.sh @@ -2,7 +2,7 @@ terraform init; terraform plan; terraform apply --auto-approve -awslocal lambda invoke --function-name bash-runtime --payload '{"text":"Hello"}' response.txt +lstk aws lambda invoke --function-name bash-runtime --payload '{"text":"Hello"}' response.txt api_id=$(aws --endpoint-url=http://localhost:4566 apigatewayv2 get-apis | jq -r .Items[0].ApiId) diff --git a/sample-archive/cloudposse-msk/README.md b/sample-archive/cloudposse-msk/README.md index ab2e5ff..64965ef 100644 --- a/sample-archive/cloudposse-msk/README.md +++ b/sample-archive/cloudposse-msk/README.md @@ -13,7 +13,7 @@ This example requires LocalStack Pro. Once you have started LocalStack, proceed to prepare a route53 zone: ```sh -awslocal route53 create-hosted-zone \ +lstk aws route53 create-hosted-zone \ --name my-kafka.localhost.localstack.cloud \ --caller-reference cli-invocation-0 ``` diff --git a/sample-archive/s3-lambda-sqs-notification/README.md b/sample-archive/s3-lambda-sqs-notification/README.md index c4d1d23..509e4ca 100644 --- a/sample-archive/s3-lambda-sqs-notification/README.md +++ b/sample-archive/s3-lambda-sqs-notification/README.md @@ -7,13 +7,13 @@ * The lambda sends messages to SQS depending on log processing logic ```bash -awslocal s3 cp example-app.log s3://app-logs-structured/example-app-01.log +lstk aws s3 cp example-app.log s3://app-logs-structured/example-app-01.log -awslocal sqs receive-message --wait-time-seconds 20 \ +lstk aws sqs receive-message --wait-time-seconds 20 \ --queue-url http://localhost:4566/000000000000/alerts-queue \ | jq -r ".Messages[0].Body" -awslocal sqs receive-message --wait-time-seconds 20 \ +lstk aws sqs receive-message --wait-time-seconds 20 \ --queue-url http://localhost:4566/000000000000/alerts-queue \ | jq -r ".Messages[0].Body" ``` diff --git a/sample-archive/s3-lambda-sqs-notification/run.sh b/sample-archive/s3-lambda-sqs-notification/run.sh index 648ba87..627a49b 100755 --- a/sample-archive/s3-lambda-sqs-notification/run.sh +++ b/sample-archive/s3-lambda-sqs-notification/run.sh @@ -6,12 +6,12 @@ terraform apply --auto-approve # run test -awslocal s3 cp example-app.log s3://app-logs-structured/example-app-01.log +lstk aws s3 cp example-app.log s3://app-logs-structured/example-app-01.log -awslocal sqs receive-message --wait-time-seconds 20 \ +lstk aws sqs receive-message --wait-time-seconds 20 \ --queue-url http://localhost:4566/000000000000/alerts-queue \ | jq -r ".Messages[0].Body" -awslocal sqs receive-message --wait-time-seconds 20 \ +lstk aws sqs receive-message --wait-time-seconds 20 \ --queue-url http://localhost:4566/000000000000/alerts-queue \ | jq -r ".Messages[0].Body" From 7427dd856822c1c6b7ed345e9b4b302f46e3eddb Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Sat, 5 Sep 2026 13:12:06 +0530 Subject: [PATCH 2/2] Configure the AWS profile on start; the lstk aws profile note corrupts jq parsing in CI Claude-Session: https://claude.ai/code/session_019Syt1j5eEeCGfuVCM78mom --- .github/workflows/makefile.yml | 2 +- common.mk | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml index e4734db..f271ba3 100644 --- a/.github/workflows/makefile.yml +++ b/.github/workflows/makefile.yml @@ -41,6 +41,6 @@ jobs: - name: Execute tests env: LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} - DEBUG: 1 + LOCALSTACK_DEBUG: 1 timeout-minutes: 100 run: make test-ci-all diff --git a/common.mk b/common.mk index 5c0163f..8253ccc 100644 --- a/common.mk +++ b/common.mk @@ -32,7 +32,8 @@ usage: ## Show this help start: ## Start LocalStack @test -n "${LOCALSTACK_AUTH_TOKEN}" || (echo "LOCALSTACK_AUTH_TOKEN is not set" && exit 1); - DEBUG=1 LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) $(LSTK) start + LOCALSTACK_DEBUG=1 LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) $(LSTK) start + $(LSTK) setup aws --force stop: ## Stop LocalStack $(LSTK) stop