Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,39 +32,37 @@ 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
lstk setup aws

- name: Start LocalStack
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
DNS_ADDRESS: 0
run: |
pip install localstack awscli-local[ver1]
pip install terraform-local
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
LOCALSTACK_DEBUG=1 LOCALSTACK_AUTH_TOKEN=$LOCALSTACK_AUTH_TOKEN lstk start --non-interactive
# Wait for the LocalStack container to become ready before timing out

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment, and the echo following it are a bit misleading. I suggest we only include best practices in our sample application, because that's what humans/agents will copy.

echo "Waiting for LocalStack startup..."
localstack wait -t 15
lstk status
echo "Startup complete"

- name: Build the SAM application
run: samlocal build
run: lstk sam build

- name: Deploy the SAM application
run: samlocal deploy --resolve-s3 --no-confirm-changeset
run: lstk sam deploy --resolve-s3 --no-confirm-changeset

- name: List the resources
run: |
awslocal sqs list-queues
awslocal sns list-topics
awslocal dynamodb list-tables
awslocal lambda list-functions
awslocal s3 ls
lstk aws sqs list-queues
lstk aws sns list-topics
lstk aws dynamodb list-tables
lstk aws lambda list-functions
lstk aws s3 ls

- name: Send a Slack notification
if: failure() || github.event_name != 'pull_request'
Expand Down
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,35 @@ usage:

## Install dependencies
install:
@which localstack || pip install localstack
@which awslocal || pip install awscli-local
@which samlocal || pip install aws-sam-cli-local
@which lstk || npm install -g @localstack/lstk
@which aws || pip install awscli
@which sam || pip install aws-sam-cli

# Deploy the infrastructure
build:
samlocal build;
lstk sam build;

## Deploy the infrastructure
deploy:
samlocal deploy --resolve-s3 --no-confirm-changeset;
lstk sam deploy --resolve-s3 --no-confirm-changeset;

## 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) DEBUG=1 localstack start -d
@LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) LOCALSTACK_DEBUG=1 lstk start --non-interactive

## Stop the Running LocalStack container
stop:
@echo
localstack stop
lstk stop

## Make sure the LocalStack container is up
ready:
@echo Waiting on the LocalStack container...

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the samples that I've modified, I generally removed the ready target, since it adds no value with lstk.

@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)

## 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 run start stop ready logs
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ 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).
- [Serverless Application Model](https://docs.localstack.cloud/user-guide/integrations/aws-sam/) with the [`samlocal`](https://github.com/localstack/aws-sam-cli-local) installed.
- [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/).
- [Serverless Application Model](https://docs.localstack.cloud/user-guide/integrations/aws-sam/) with `aws-sam-cli` installed, used via the `lstk sam` proxy.
- [AWS CLI](https://docs.localstack.cloud/user-guide/integrations/aws-cli/), required by `lstk aws`.
- [Python 3.9.0](https://www.python.org/downloads/release/python-390/) in the `PATH`

## Start LocalStack
Expand All @@ -51,7 +51,7 @@ make start
make ready
```

We specified `DEBUG=1` to get the printed LocalStack logs directly in the terminal to help us see the event-driven architecture 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 `LOCALSTACK_DEBUG=1` to get the printed LocalStack logs directly in the terminal to help us see the event-driven architecture in action. If you prefer running LocalStack in the background, you can add the `--non-interactive` flag to the `lstk start` command, and use Docker Desktop to view the logs.

@peter-smith-phd peter-smith-phd Aug 24, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not correct, since lstk always run in a detached mode, and not just when --non-interactive is used.


## Instructions

Expand All @@ -62,7 +62,7 @@ You can build and deploy the sample application on LocalStack by running our `Ma
To build the SAM application, run the following command:

```shell
samlocal build
lstk sam build
```

If you see a `Build Succeeded` message, you can proceed to the next step.
Expand All @@ -74,24 +74,24 @@ If you see a `Build Succeeded` message, you can proceed to the next step.
To deploy the SAM application, run the following command:

```shell
samlocal deploy --resolve-s3
lstk sam deploy --resolve-s3
```

The above command will create a new managed S3 bucket to store the artifacts of the SAM application. If you want to use an existing S3 bucket, you can use the `--s3-bucket` flag to specify the bucket name. Before being deployed, the CloudFormation changeset will be displayed in the terminal. If you want to deploy the application without confirmation, you can use the `--no-confirm-changeset` flag.

To view the created resources, check out the CloudFormation outputs from deployed stack or run the following commands

```shell
awslocal sqs list-queues
awslocal sns list-topics
awslocal dynamodb list-tables
awslocal lambda list-functions
awslocal s3 ls
lstk aws sqs list-queues
lstk aws sns list-topics
lstk aws dynamodb list-tables
lstk aws lambda list-functions
lstk aws s3 ls
```

### Testing the application

After a successful deployment, you can test the application's functionality by checking out the LocalStack logs (`localstack logs`). For more verbose logs, we have enabled `DEBUG=1`, and you can alternatively set `LS_LOG=trace-internal` to see internal calls between different services.
After a successful deployment, you can test the application's functionality by checking out the LocalStack logs (`lstk logs`). For more verbose logs, we have enabled `LOCALSTACK_DEBUG=1`, and you can alternatively set `LS_LOG=trace-internal` to see internal calls between different services.

We offer **Resource Browsers** in the LocalStack Web Application to help you visualize the resources created by the application. You can access the Web Application by visiting [**app.localstack.cloud**](https://app.localstack.cloud) in your browser. Navigate to the [CloudWatch Log Groups](https://app.localstack.cloud/resources/cloudwatch/groups) to verify the Log groups.

Expand Down
Loading