Skip to content

Commit 11e96db

Browse files
Migrate from awslocal, cdklocal, and setup-localstack to lstk (#19)
1 parent e7459ba commit 11e96db

5 files changed

Lines changed: 47 additions & 49 deletions

File tree

.github/workflows/cloud-pods.yml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,21 @@ jobs:
3131
run: |
3232
make install
3333
34+
35+
- name: Install lstk
36+
run: |
37+
npm install -g @localstack/lstk
38+
3439
- name: Install CDK
3540
run: |
36-
npm install -g aws-cdk-local aws-cdk
37-
cdklocal --version
41+
npm install -g aws-cdk
3842
3943
- name: Start LocalStack
40-
uses: LocalStack/setup-localstack@main
41-
with:
42-
image-tag: 'latest'
43-
use-pro: 'true'
44-
configuration: LS_LOG=trace
45-
install-awslocal: 'true'
4644
env:
4745
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
46+
LOCALSTACK_LS_LOG: trace
47+
run: |
48+
lstk start
4849
4950
- name: Deploy the application
5051
env:
@@ -58,13 +59,12 @@ jobs:
5859
env:
5960
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
6061
run: |
61-
message="Cloud Pod created: sample-cdk-rds on $(date) with workflow run id: ${{ github.run_id }}"
62-
localstack pod save sample-cdk-rds --message "$message"
62+
lstk snapshot save pod:sample-cdk-rds
6363
6464
- name: Show LocalStack Logs
6565
if: always()
6666
run: |
67-
localstack logs
67+
lstk logs
6868
6969
test-cloud-pod:
7070
name: Test Cloud Pod
@@ -80,20 +80,22 @@ jobs:
8080
node-version: 22
8181
cache: 'npm'
8282

83+
- name: Install lstk
84+
run: |
85+
npm install -g @localstack/lstk
86+
8387
- name: Start LocalStack
84-
uses: LocalStack/setup-localstack@main
85-
with:
86-
use-pro: 'true'
87-
install-awslocal: 'true'
8888
env:
89-
DEBUG: 1
9089
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
90+
LOCALSTACK_DEBUG: 1
91+
run: |
92+
lstk start
9193
9294
- name: Load Cloud Pod
9395
env:
9496
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
9597
run: |
96-
localstack pod load sample-cdk-rds
98+
lstk snapshot load pod:sample-cdk-rds
9799
98100
- name: Install dependencies
99101
run: |
@@ -106,7 +108,7 @@ jobs:
106108
- name: Show LocalStack Logs
107109
if: always()
108110
run: |
109-
localstack logs
111+
lstk logs
110112
111113
- name: Send a Slack notification
112114
if: failure() || github.event_name != 'pull_request'

.github/workflows/main.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@ jobs:
3232
run: |
3333
make install
3434
35+
- name: Install lstk
36+
run: |
37+
npm install -g @localstack/lstk
38+
3539
- name: Install CDK
3640
run: |
37-
npm install -g aws-cdk-local aws-cdk
38-
cdklocal --version
41+
npm install -g aws-cdk
3942
4043
- name: Start LocalStack
41-
uses: LocalStack/setup-localstack@v0.2.4
42-
with:
43-
image-tag: 'latest'
44-
use-pro: 'true'
45-
configuration: LS_LOG=trace
46-
install-awslocal: 'true'
4744
env:
4845
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
46+
LOCALSTACK_LS_LOG: trace
47+
run: |
48+
lstk start
4949
5050
- name: Deploy the application
5151
env:
@@ -62,7 +62,7 @@ jobs:
6262
- name: Show Logs
6363
if: always()
6464
run: |
65-
localstack logs
65+
lstk logs
6666
6767
- name: Send a Slack notification
6868
if: failure() || github.event_name != 'pull_request'

Makefile

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ check: ## Check if all required prerequisites are installed
1212
@command -v docker > /dev/null 2>&1 || { echo "Docker is not installed. Please install Docker and try again."; exit 1; }
1313
@command -v node > /dev/null 2>&1 || { echo "Node.js is not installed. Please install Node.js and try again."; exit 1; }
1414
@command -v aws > /dev/null 2>&1 || { echo "AWS CLI is not installed. Please install AWS CLI and try again."; exit 1; }
15-
@command -v localstack > /dev/null 2>&1 || { echo "LocalStack is not installed. Please install LocalStack and try again."; exit 1; }
1615
@command -v cdk > /dev/null 2>&1 || { echo "CDK is not installed. Please install CDK and try again."; exit 1; }
17-
@command -v cdklocal > /dev/null 2>&1 || { echo "cdklocal is not installed. Please install cdklocal and try again."; exit 1; }
16+
@command -v lstk > /dev/null 2>&1 || { echo "lstk is not installed. Please install lstk and try again."; exit 1; }
1817
@command -v aws > /dev/null 2>&1 || { echo "AWS CLI is not installed. Please install AWS CLI and try again."; exit 1; }
19-
@command -v awslocal > /dev/null 2>&1 || { echo "awslocal is not installed. Please install awslocal and try again."; exit 1; }
2018
@echo "All required prerequisites are available."
2119

2220
install: ## Install all required dependencies
@@ -32,9 +30,9 @@ install: ## Install all required dependencies
3230

3331
deploy: ## Deploy the CDK stack
3432
@echo "Bootstrapping CDK..."
35-
cdklocal bootstrap
33+
lstk cdk bootstrap
3634
@echo "Deploying CDK..."
37-
cdklocal deploy --require-approval never
35+
lstk cdk deploy --require-approval never
3836
@echo "CDK deployed successfully."
3937

4038
test: ## Run the tests
@@ -47,35 +45,34 @@ run: ## Execute a SQL query through the Lambda function
4745
@aws_version=$$(aws --version | grep -o "aws-cli/[0-9]*" | cut -d'/' -f2); \
4846
if [ "$$aws_version" = "2" ]; then \
4947
echo "Using AWS CLI version 2 command format..."; \
50-
awslocal lambda invoke \
48+
lstk aws lambda invoke \
5149
--cli-binary-format raw-in-base64-out \
5250
--function-name my-lambda-rds-query-helper \
5351
--payload '{"sqlQuery": "select Author from books", "secretName":"/rdsinitexample/rds/creds/mysql-01"}' output; \
5452
else \
5553
echo "Using AWS CLI version 1 command format..."; \
56-
awslocal lambda invoke \
54+
lstk aws lambda invoke \
5755
--function-name my-lambda-rds-query-helper \
5856
--payload '{"sqlQuery": "select Author from books", "secretName":"/rdsinitexample/rds/creds/mysql-01"}' output; \
5957
fi
6058
@echo "Query execution completed. Results:"
6159
@cat output
6260

63-
start: ## Start LocalStack in detached mode
61+
start: ## Start LocalStack (blocks until ready)
6462
@echo "Starting LocalStack..."
6563
@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)
66-
@LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) localstack start -d
64+
@LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) lstk start
6765
@echo "LocalStack started successfully."
6866

6967
stop: ## Stop LocalStack
7068
@echo "Stopping LocalStack..."
71-
@localstack stop
69+
@lstk stop
7270
@echo "LocalStack stopped successfully."
7371

74-
ready: ## Wait for LocalStack to be ready
75-
@echo Waiting on the LocalStack container...
76-
@localstack wait -t 30 && echo LocalStack is ready to use! || (echo Gave up waiting on LocalStack, exiting. && exit 1)
72+
ready: ## Confirm LocalStack is ready (lstk start already waits, so this just reports status)
73+
@lstk status
7774

7875
logs: ## Get LocalStack logs
79-
@localstack logs > logs.txt
76+
@lstk logs > logs.txt
8077

8178
.PHONY: usage check start ready install deploy test logs stop

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ The following diagram shows the architecture that this sample application builds
2727
## Prerequisites
2828

2929
- 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.
30-
- [`localstack` CLI](https://docs.localstack.cloud/getting-started/installation/#localstack-cli).
31-
- [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).
32-
- [CDK](https://docs.localstack.cloud/user-guide/integrations/aws-cdk/) with the [`cdklocal`](https://www.npmjs.com/package/aws-cdk-local) wrapper.
30+
- [`lstk` CLI](https://docs.localstack.cloud/aws/tooling/lstk/).
31+
- [AWS CLI](https://docs.localstack.cloud/user-guide/integrations/aws-cli/) with the [`lstk aws` proxy](https://docs.localstack.cloud/aws/tooling/lstk/).
32+
- [CDK](https://docs.localstack.cloud/user-guide/integrations/aws-cdk/) with the [`lstk cdk` proxy](https://docs.localstack.cloud/aws/tooling/lstk/).
3333
- [Node.js](https://nodejs.org/en/download/)
3434
- [`make`](https://www.gnu.org/software/make/) (**optional**, but recommended for running the sample application)
3535

@@ -60,8 +60,7 @@ make install
6060
Start LocalStack with the `LOCALSTACK_AUTH_TOKEN` pre-configured:
6161

6262
```shell
63-
localstack auth set-token <your-auth-token>
64-
localstack start
63+
lstk start
6564
```
6665
> [!NOTE]
6766
> By default, LocalStack uses the MariaDB engine (see [RDS documentation](https://docs.localstack.cloud/user-guide/aws/rds/#mysql-engine)).
@@ -104,15 +103,15 @@ This function requires two parameters:
104103
To run a query using AWS CLI version 1, you can invoke the Lambda function with the following command:
105104

106105
```shell
107-
awslocal lambda invoke \
106+
lstk aws lambda invoke \
108107
--function-name my-lambda-rds-query-helper \
109108
--payload '{"sqlQuery": "select Author from books", "secretName":"/rdsinitexample/rds/creds/mysql-01"}' output
110109
```
111110

112111
If you are using AWS CLI version 2, the command must include an additional flag for payload formatting:
113112

114113
```shell
115-
awslocal lambda invoke \
114+
lstk aws lambda invoke \
116115
--cli-binary-format raw-in-base64-out \
117116
--function-name my-lambda-rds-query-helper \
118117
--payload '{"sqlQuery": "select Author from books", "secretName":"/rdsinitexample/rds/creds/mysql-01"}' output

demos/rds-query-fn-code/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const secrets = new SecretsManagerClient({
1919

2020
// the function expects "secretName" and "sqlQuery" as payload
2121
// sample call using aws-cli:
22-
// $ awslocal lambda invoke --function-name my-lambda-rds-query-helper --payload '{"sqlQuery": "select Author from books", "secretName":"/rdsinitexample/rds/creds/mysql-01"}' output
22+
// $ lstk aws lambda invoke --function-name my-lambda-rds-query-helper --payload '{"sqlQuery": "select Author from books", "secretName":"/rdsinitexample/rds/creds/mysql-01"}' output
2323
// the result is in the 'output' file:
2424
// $ cat output
2525
exports.handler = async (event, context) => {

0 commit comments

Comments
 (0)