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
18 changes: 8 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,20 @@ jobs:
with:
node-version: 18

- name: Install lstk
run: npm install -g @localstack/lstk

- name: Start LocalStack
uses: LocalStack/setup-localstack@main
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
DNS_ADDRESS: 0
DEBUG: 1
with:
use-pro: 'true'

- name: Install tflocal
run: pip install terraform-local
LOCALSTACK_DNS_ADDRESS: "0"
LOCALSTACK_DEBUG: "1"
run: lstk start

- name: Install CDK
run: |
npm install -g aws-cdk-local aws-cdk
cdklocal --version
npm install -g aws-cdk
lstk cdk --version

- name: Install dependencies
run: yarn
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: Create PR Preview

on:
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
# Disabled: `lstk aws`/`lstk cdk` (used via the Makefile targets that preview-cmd
# below calls) always target their own locally-managed emulator and ignore
# AWS_ENDPOINT_URL, so they can't reach the remote ephemeral instance this
# workflow provisions. Re-enable once that's resolved.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is already resolved, although the lstk docs haven't been updated to reflect that AWS_ENDPOINT_URL is now recognized.

# pull_request:
# types: [opened, synchronize, reopened]

jobs:
preview:
Expand All @@ -22,18 +27,20 @@ jobs:
state-backend: ephemeral
state-action: start
include-preview: 'true'
# TODO(lstk): no install-lstk equivalent in the setup-localstack action yet —

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What is the intention of this TODO? lstk aws is already part of lstk, so all that's required is for aws to be installed.

# lstk is installed via npm inside preview-cmd instead.
install-awslocal: 'true'
# Multi line commands are folding for some reason, so we enforce new lines
# For more predictable usage, use script files
preview-cmd: |
npm install -g aws-cdk-local aws-cdk;
npm install -g @localstack/lstk aws-cdk;
make build;
make bootstrap;
make deploy;
make prepare-frontend-local;
make build-frontend;
make bootstrap-frontend;
make deploy-frontend;
distributionId=$(awslocal cloudfront list-distributions | jq -r '.DistributionList.Items[0].Id');
distributionId=$(lstk aws cloudfront list-distributions | jq -r '.DistributionList.Items[0].Id');
echo LS_PREVIEW_URL=$AWS_ENDPOINT_URL/cloudfront/$distributionId/ >> $GITHUB_ENV;

11 changes: 5 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ usage:

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

# Deploy the infrastructure
build:
Expand All @@ -29,7 +28,7 @@ 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 --non-interactive

## export configs for web app
prepare-frontend-local:
Expand All @@ -50,16 +49,16 @@ deploy-frontend:
## 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...
@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

setup-challenge:
yarn install
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ 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).
- [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).
- [CDK](https://docs.localstack.cloud/user-guide/integrations/aws-cdk/) with the [`cdklocal`](https://www.npmjs.com/package/aws-cdk-local) wrapper.
- 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`.
- [AWS CLI](https://docs.localstack.cloud/user-guide/integrations/aws-cli/), required by `lstk aws`.
- [CDK](https://docs.localstack.cloud/user-guide/integrations/aws-cdk/), used via the `lstk cdk` proxy.
- [Node.js](https://nodejs.org/en/download/) with `yarn` package manager.

Start LocalStack for AWS with the `LOCALSTACK_AUTH_TOKEN` pre-configured:

```shell
export LOCALSTACK_AUTH_TOKEN=<your-auth-token>
EXTRA_CORS_ALLOWED_ORIGINS=* localstack start
EXTRA_CORS_ALLOWED_ORIGINS=* lstk start
```

The `EXTRA_CORS_ALLOWED_ORIGINS` configuration variable allows our website to send requests to the HTTP APIs exposed via the API Gateway. 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.
The `EXTRA_CORS_ALLOWED_ORIGINS` configuration variable allows our website to send requests to the HTTP APIs exposed via the API Gateway. If you prefer running LocalStack in detached mode, 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 Down Expand Up @@ -170,6 +170,8 @@ Users can adapt this example workflow to run in their own CI environment. LocalS

This sample further shows off our preview environments feature. Preview environments allow you to deploy your application to a separate environment whenever you want with the right configuration. You can find the workflow in the `.github/workflows/preview.yml` file. You can find more information about preview environments in the [LocalStack documentation](https://docs.localstack.cloud/user-guide/cloud-sandbox/application-previews/).

> This workflow provisions a remote Ephemeral Instance via the `LocalStack/setup-localstack` action, which `lstk` does not support yet. Its automatic `pull_request` trigger has been disabled; it can still be run manually via `workflow_dispatch`.

## Learn more

The sample application is based on a public [AWS sample app](https://github.com/aws-samples/ecs-apigateway-sample) and a [SST tutorial](https://github.com/serverless-stack/demo-notes-app).
Expand Down
4 changes: 2 additions & 2 deletions packages/infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"scripts": {
"build": "tsc",
"cdk": "tsc && cdk",
"cdklocal": "tsc && cdklocal --require-approval never"
"cdklocal": "tsc && lstk cdk --require-approval never"
},
"devDependencies": {
"@types/node": "^18.11.18",
"aws-cdk": "2.59.0",
"aws-cdk": "2.1133.0",
"typescript": "~4.9.4"
},
"dependencies": {
Expand Down
34 changes: 5 additions & 29 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ __metadata:
resolution: "@aws-sdk-notes-app/infra@workspace:packages/infra"
dependencies:
"@types/node": ^18.11.18
aws-cdk: 2.59.0
aws-cdk: 2.1133.0
aws-cdk-lib: 2.59.0
constructs: 10.1.215
typescript: ~4.9.4
Expand Down Expand Up @@ -2573,17 +2573,12 @@ __metadata:
languageName: node
linkType: hard

"aws-cdk@npm:2.59.0":
version: 2.59.0
resolution: "aws-cdk@npm:2.59.0"
dependencies:
fsevents: 2.3.2
dependenciesMeta:
fsevents:
optional: true
"aws-cdk@npm:2.1133.0":
version: 2.1133.0
resolution: "aws-cdk@npm:2.1133.0"
bin:
cdk: bin/cdk
checksum: 2d405f43d7d1c857ab27e42b861953a3ea4712e57356f556d97382d7ce25749be60896b2a9982d69b60e825dc0a749fc31d31974637c09149a8dea0796d11171
checksum: 89525d4e74669a82da3a13386602257780184d200fd4492e3f36ff1e9189118ff3de814e9096bac4b9cc85f9989516e5f94aa71a7e544eb8d544497e127b7f3f
languageName: node
linkType: hard

Expand Down Expand Up @@ -3683,16 +3678,6 @@ __metadata:
languageName: node
linkType: hard

"fsevents@npm:2.3.2":
version: 2.3.2
resolution: "fsevents@npm:2.3.2"
dependencies:
node-gyp: latest
checksum: 97ade64e75091afee5265e6956cb72ba34db7819b4c3e94c431d4be2b19b8bb7a2d4116da417950c3425f17c8fe693d25e20212cac583ac1521ad066b77ae31f
conditions: os=darwin
languageName: node
linkType: hard

"fsevents@npm:~2.3.2":
version: 2.3.3
resolution: "fsevents@npm:2.3.3"
Expand All @@ -3703,15 +3688,6 @@ __metadata:
languageName: node
linkType: hard

"fsevents@patch:fsevents@2.3.2#~builtin<compat/fsevents>":
version: 2.3.2
resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin<compat/fsevents>::version=2.3.2&hash=df0bf1"
dependencies:
node-gyp: latest
conditions: os=darwin
languageName: node
linkType: hard

"fsevents@patch:fsevents@~2.3.2#~builtin<compat/fsevents>":
version: 2.3.3
resolution: "fsevents@patch:fsevents@npm%3A2.3.3#~builtin<compat/fsevents>::version=2.3.3&hash=df0bf1"
Expand Down
Loading