Skip to content

Commit 0ea705a

Browse files
authored
Require LocalStack license and standardize sample documentation (#269)
* Require LocalStack license and standardize documentation across all samples - Add LOCALSTACK_AUTH_TOKEN check to all `start` Makefile targets - Remove deprecated ACTIVATE_PRO=1 from all Makefiles - Add `check` target for prerequisite validation to all Makefiles - Create Makefiles for 11 samples that were missing them - Rewrite all sample READMEs to match gold standard format with key/value tables - Add license prerequisite as first bullet in all READMEs - Create missing READMEs for cdk-for-terraform, emr-serverless-sample, lambda-function-urls-python, lambda-hot-reloading, lambda-xray - Update root README Configuration section and add 11 missing table entries - Fix broken lambda-function-urls link in root README * trigger CI * try to run * Fix auth token guidance and missing prerequisites across all samples - Update all 48 Makefiles: change error URL from /pricing to /workspace/auth-token so users land on the token page directly - Update all 48 READMEs: expand license bullet to include explicit export LOCALSTACK_AUTH_TOKEN=<your-auth-token> instruction with a link to the LocalStack Web Application - Fix apigw-custom-domain/README.md: add missing license bullet, Docker, localstack CLI, and awslocal CLI prerequisites; remove stale Environment row from the metadata table * Move auth token setup into Start LocalStack section in all READMEs - Revert Prerequisites license bullet to simple one-liner (no inline code block or web app link) - Add explicit 'export LOCALSTACK_AUTH_TOKEN=<your-auth-token>' as the first command in the Start LocalStack code block across all sample READMEs (47 make start + 1 localstack start variant) * restore DEBUG=1, expected outputs, and missing context
1 parent 6eda9cf commit 0ea705a

File tree

100 files changed

+2828
-1084
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+2828
-1084
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,21 @@ jobs:
3636
- name: Setup Node.js
3737
uses: actions/setup-node@v4
3838
with:
39-
node-version: 18
39+
node-version: 20
40+
4041
- name: Install LocalStack
4142
run: pip install localstack awscli-local[ver1] virtualenv
43+
4244
- name: Setup config
4345
run: |
4446
echo "Configuring git for codecommit sample"
4547
git config --global user.email "localstack.sample@localstack.cloud"
4648
git config --global user.name "Localstack Pro-Samples"
49+
4750
- name: Pull the latest docker image
4851
run: docker pull localstack/localstack-pro
49-
- name: Execute a simple test
52+
53+
- name: Execute tests
5054
timeout-minutes: 10
5155
run: |
5256
cd ${{ matrix.directory }}

README.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# LocalStack Pro Samples
22

3-
This repository contains sample projects that can be deployed on your local machine using [LocalStack Pro](https://localstack.cloud/).
3+
This repository contains sample projects that can be deployed on your local machine using [LocalStack](https://localstack.cloud/).
44

55
Each example in the repository is prefixed with the name of the AWS service being used. For example, the `elb-load-balancing` directory contains examples that demonstrate how to use the Elastic Load Balancing service with LocalStack. Please refer to the sub directories for more details and instructions on how to start the samples.
66

@@ -14,14 +14,27 @@ Each example in the repository is prefixed with the name of the AWS service bein
1414

1515
## Configuration
1616

17-
Some of the samples require LocalStack Pro features. Please make sure to properly configure the `LOCALSTACK_AUTH_TOKEN` environment variable. You can find your Auth Token on the [LocalStack Web Application](https://app.localstack.cloud/workspace/auth-token) and you can refer to our [Auth Token documentation](https://docs.localstack.cloud/getting-started/auth-token/) for more details.
17+
All samples require 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. Set it before running any sample:
18+
19+
```bash
20+
export LOCALSTACK_AUTH_TOKEN=<your-auth-token>
21+
```
22+
23+
Alternatively, use the LocalStack CLI to persist the token:
24+
25+
```bash
26+
localstack auth set-token <your-auth-token>
27+
```
28+
29+
You can find your Auth Token on the [LocalStack Web Application](https://app.localstack.cloud/workspace/auth-token).
1830

1931
## Outline
2032

2133
| Sample Name | Description |
2234
| -------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
2335
| [Serverless Websockets](serverless-websockets) | API Gateway V2 websocket APIs deployed via the Serverless framework |
2436
| [RDS Database Queries](rds-db-queries) | Running queries locally against an RDS database |
37+
| [RDS Failover Test](rds-failover-test) | Running a failover test against an RDS global cluster |
2538
| [Neptune Graph Database](neptune-graph-db) | Running queries locally against a Neptune Graph database |
2639
| [Lambda Event Filtering](lambda-event-filtering) | Lambda event source filtering with DynamoDB and SQS |
2740
| [Glacier & S3 select queries](glacier-s3-select) | Using Glacier API and running S3 Select queries locally |
@@ -42,7 +55,9 @@ Some of the samples require LocalStack Pro features. Please make sure to properl
4255
| [ECS ECR Container application](ecs-ecr-container-app) | Pushing Docker images to ECR and running them locally on ECS |
4356
| [Athena queries over S3](athena-s3-queries) | Running Athena queries over S3 files locally |
4457
| [Terraform resources](terraform-resources) | Deploying various AWS resources via Terraform |
45-
| [Lambda Function URLs](lambda-function-urls) | Invoking Lambda functions via HTTP(s) URLs |
58+
| [CDK for Terraform resources](cdk-for-terraform) | Deploying AWS resources via CDK for Terraform |
59+
| [Lambda Function URLs (JavaScript)](lambda-function-urls-javascript) | Invoking Lambda functions via HTTP(S) URLs using JavaScript |
60+
| [Lambda Function URLs (Python)](lambda-function-urls-python) | Invoking Lambda functions via HTTP(S) URLs using Python |
4661
| [Sagemaker inference](sagemaker-inference) | Creating & invoking a Sagemaker endpoint locally with MNIST dataset |
4762
| [MSK with Glue Schema Registry](glue-msk-schema-registry) | Use of MSK, Glue Schema Registry, Glue ETL, and RDS |
4863
| [AppSync GraphQL](appsync-graphql-api) | Deploying a GraphQL API using AppSync |
@@ -59,6 +74,13 @@ Some of the samples require LocalStack Pro features. Please make sure to properl
5974
| [ELB Load Balancing](elb-load-balancing) | Using ELBv2 Application Load Balancers locally, deployed via the Serverless framework |
6075
| [Reproducible ML](reproducible-ml) | Train, save and evaluate a scikit-learn machine learning model using AWS Lambda and S3 |
6176
| [Lambda PHP/Bref CDK App](lambda-php-bref-cdk-app) | Running PHP/Bref Lambda handler locally, deployed via AWS CDK |
77+
| [Step Functions with Lambda](stepfunctions-lambda) | Orchestrating Lambda functions using AWS Step Functions |
78+
| [Multi-Account S3 Access](multi-account-multi-region-s3-access) | Accessing S3 resources across different AWS accounts and regions |
79+
| [Route53 DNS Failover](route53-dns-failover) | Route53 DNS failover based on health checks |
80+
| [EMR Serverless Sample](emr-serverless-sample) | Running EMR Serverless jobs locally |
81+
| [EMR Serverless Spark](emr-serverless-spark) | Running Java Spark jobs on EMR Serverless |
82+
| [EMR Serverless Python Dependencies](emr-serverless-python-dependencies) | Adding Python dependencies to EMR Serverless PySpark jobs |
83+
| [Testcontainers Java Sample](testcontainers-java-sample) | Using LocalStack Testcontainers with RDS in Java |
6284

6385
## Checking out a single sample
6486

@@ -104,6 +126,7 @@ run: ## Run the actual sample steps/commands. This assumes LocalStack is
104126
./run.sh
105127

106128
start: ## Start LocalStack in detached mode
129+
@test -n "${LOCALSTACK_AUTH_TOKEN}" || (echo "LOCALSTACK_AUTH_TOKEN is not set. Get your auth token at https://localstack.cloud/pricing."; exit 1)
107130
localstack start -d
108131

109132
stop: ## Stop the Running LocalStack container
@@ -117,9 +140,9 @@ ready: ## Make sure the LocalStack container is up
117140
logs: ## Save the logs in a separate file, since the LS container will only contain the logs of the last sample run.
118141
@localstack logs > logs.txt
119142

120-
test-ci: ## Execute the necessary targets in the correct order for an automatic execution.
143+
test-ci: ## Execute the necessary targets in the correct order for an automatic execution.
121144
make start install ready run; return_code=`echo $$?`;\
122145
make logs; make stop; exit $$return_code;
123146

124147
.PHONY: usage install run start stop ready logs test-ci
125-
```
148+
```

apigw-custom-domain/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ test: ## Run tests
5555
make deploy run target=ci
5656

5757
start: ## Start LocalStack
58-
ACTIVATE_PRO=1 localstack start -d
58+
@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)
59+
localstack start -d
5960

6061
stop: ## Stop LocalStack
6162
@echo

apigw-custom-domain/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
| Key | Value |
44
| ------------ | --------------------------------- |
5-
| Environment | LocalStack |
65
| Services | API Gateway, Lambda, Route53, ACM |
76
| Integrations | Serverless Framework |
87
| Categories | Serverless; REST API |
@@ -15,9 +14,13 @@ Under the hood, the Serverless framework uses the [`serverless-localstack`](http
1514

1615
## Prerequisites
1716

18-
* [Node.js 18.x](https://nodejs.org/en/download/package-manager) with `npm`
19-
* [Serverless Framework](https://www.serverless.com/framework/docs/getting-started) 3.x
20-
* `openssl`
17+
- 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.
18+
- [Docker](https://docs.docker.com/get-docker/)
19+
- [`localstack` CLI](https://docs.localstack.cloud/getting-started/installation/#localstack-cli)
20+
- [`awslocal` CLI](https://docs.localstack.cloud/user-guide/integrations/aws-cli/)
21+
- [Node.js 18.x](https://nodejs.org/en/download/package-manager) with `npm`
22+
- [Serverless Framework](https://www.serverless.com/framework/docs/getting-started) 3.x
23+
- `openssl`
2124

2225
## Check prerequisites
2326

@@ -34,6 +37,7 @@ make install
3437
## Start LocalStack
3538

3639
```bash
40+
export LOCALSTACK_AUTH_TOKEN=<your-auth-token>
3741
make start
3842
```
3943

appsync-graphql-api/Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ SHELL := /bin/bash
77
usage: ## Show this help
88
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
99

10+
check: ## Check if all required prerequisites are installed
11+
@command -v docker > /dev/null 2>&1 || { echo "Docker is not installed. Please install Docker and try again."; exit 1; }
12+
@command -v node > /dev/null 2>&1 || { echo "Node.js is not installed. Please install Node.js and try again."; exit 1; }
13+
@command -v python3 > /dev/null 2>&1 || { echo "Python 3 is not installed. Please install Python 3 and try again."; exit 1; }
14+
@command -v localstack > /dev/null 2>&1 || { echo "LocalStack CLI is not installed. Please install it and try again."; exit 1; }
15+
@command -v awslocal > /dev/null 2>&1 || { echo "awslocal is not installed. Please run: pip install awscli-local"; exit 1; }
16+
@echo "All required prerequisites are available."
17+
18+
1019
install: ## Install dependencies
1120
@test -e node_modules || npm install
1221
@which serverless || npm install -g serverless
@@ -17,7 +26,8 @@ install: ## Install dependencies
1726
run: ## Deploy the app locally and run an AppSync GraphQL test invocation
1827
./run.sh
1928
start:
20-
localstack start -d
29+
@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)
30+
DEBUG=1 LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) localstack start -d
2131

2232
stop:
2333
@echo

appsync-graphql-api/README.md

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,68 @@
1-
# LocalStack Demo: AppSync GraphQL APIs for DynamoDB and RDS Aurora Postgres
1+
# AppSync GraphQL API
22

3-
Simple demo application illustrating how to proxy data from different resources (DynamoDB tables, RDS databases) via AppSync GraphQL using LocalStack.
3+
| Key | Value |
4+
| ------------ | ----------------------------------- |
5+
| Services | AppSync, DynamoDB, RDS |
6+
| Integrations | AWS SDK, AWS CLI |
7+
| Categories | GraphQL; Serverless |
8+
9+
## Introduction
10+
11+
A demo application illustrating how to proxy data from different resources (DynamoDB tables, RDS Aurora Postgres databases) via AppSync GraphQL using LocalStack. The sample runs mutation and query operations for two data sources and demonstrates real-time notifications via WebSocket subscriptions.
412

513
## Prerequisites
614

7-
* LocalStack
8-
* Docker
9-
* Python 3.6+
10-
* `make`
15+
- 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.
16+
- [Docker](https://docs.docker.com/get-docker/)
17+
- [`localstack` CLI](https://docs.localstack.cloud/getting-started/installation/#localstack-cli)
18+
- [`awslocal` CLI](https://docs.localstack.cloud/user-guide/integrations/aws-cli/)
19+
- [Python 3](https://www.python.org/downloads/)
1120

12-
## Installing
21+
## Check prerequisites
1322

14-
To install the dependencies:
23+
```bash
24+
make check
1525
```
26+
27+
## Installation
28+
29+
```bash
1630
make install
1731
```
1832

19-
## Starting LocalStack
33+
## Start LocalStack
2034

21-
Make sure that LocalStack is started:
22-
```
23-
LOCALSTACK_AUTH_TOKEN=... DEBUG=1 localstack start
35+
```bash
36+
export LOCALSTACK_AUTH_TOKEN=<your-auth-token>
37+
make start
2438
```
2539

26-
## Running
40+
## Run the application
2741

28-
Deploy the app locally and run the GraphQL test invocations:
29-
```
42+
```bash
3043
make run
3144
```
3245

33-
The demo will run different GraphQL queries, for two different datasources (DynamoDB / RDS Aurora):
46+
The script:
3447

35-
1. a mutation query which inserts a new item into DynamoDB / RDS Aurora
36-
2. a query which scans and returns the items from DynamoDB / RDS Aurora
48+
- Deploys AppSync GraphQL API with DynamoDB and RDS Aurora Postgres resolvers.
49+
- Runs mutation queries to insert items into both data sources.
50+
- Runs query operations to scan and return items from DynamoDB and RDS Aurora.
51+
- Connects a WebSocket client to verify real-time subscription notifications.
3752

3853
You should see a success output in the terminal:
39-
```
54+
55+
```bash
4056
{"data":{"addPostDDB":{"id":{"S":"id123"}}}}
4157
{"data":{"getPostsDDB":[{"id":{"S":"id123"}}]}}
4258
...
4359
{"data":{"addPostRDS":{"id":{"S":"id123"}}}}
4460
{"data":{"getPostsRDS":[{"id":{"S":"id123"}}]}}
4561
```
4662

47-
... and the item should have been added to your local DynamoDB table (as well as your RDS database):
48-
```
63+
The item should also have been added to your local DynamoDB table:
64+
65+
```bash
4966
$ awslocal dynamodb scan --table-name table1
5067
{
5168
"Items": [
@@ -61,9 +78,9 @@ $ awslocal dynamodb scan --table-name table1
6178
}
6279
```
6380

64-
Finally, you should also see a message printed from the WebSocket client subscribed to notifications from the API:
65-
```
66-
...
81+
Finally, you should see a notification from the WebSocket client:
82+
83+
```bash
6784
Starting a WebSocket client to subscribe to GraphQL mutation operations.
6885
Connecting to WebSocket URL ws://localhost:4510/graphql/...
6986
...

athena-s3-queries/Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ export AWS_DEFAULT_REGION=us-east-1
66
usage: ## Show this help
77
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
88

9+
check: ## Check if all required prerequisites are installed
10+
@command -v docker > /dev/null 2>&1 || { echo "Docker is not installed. Please install Docker and try again."; exit 1; }
11+
@command -v localstack > /dev/null 2>&1 || { echo "LocalStack CLI is not installed. Please install it and try again."; exit 1; }
12+
@command -v awslocal > /dev/null 2>&1 || { echo "awslocal is not installed. Please run: pip install awscli-local"; exit 1; }
13+
@echo "All required prerequisites are available."
14+
15+
916
install: ## Install dependencies
1017
# @test -e node_modules || npm install
1118
@which localstack || pip install localstack
@@ -16,7 +23,8 @@ run: ## Set up database connections and run Athena queries locally
1623
echo "Running Athena queries"; \
1724
./run.sh
1825
start:
19-
localstack start -d
26+
@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)
27+
DEBUG=1 LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) localstack start -d
2028

2129
stop:
2230
@echo

athena-s3-queries/README.md

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,57 @@
1-
# LocalStack Demo: Athena Queries over S3 Files
1+
# Athena Queries over S3 Files
22

3-
Simple demo application illustrating how to run Athena queries over S3 files locally, using LocalStack.
3+
| Key | Value |
4+
| ------------ | ------------------------------ |
5+
| Services | Athena, S3 |
6+
| Integrations | AWS CLI |
7+
| Categories | Analytics; Serverless |
8+
9+
## Introduction
10+
11+
A demo application illustrating how to run Athena queries over S3 files locally using LocalStack. The sample uploads CSV test data to S3, creates Athena table metadata, and runs SQL queries to aggregate results — all without connecting to AWS.
412

513
## Prerequisites
614

7-
* LocalStack
8-
* Docker
9-
* Node.js / `npm`
10-
* `make`
15+
- 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.
16+
- [Docker](https://docs.docker.com/get-docker/)
17+
- [`localstack` CLI](https://docs.localstack.cloud/getting-started/installation/#localstack-cli)
18+
- [`awslocal` CLI](https://docs.localstack.cloud/user-guide/integrations/aws-cli/)
19+
- [Node.js](https://nodejs.org/en/download/) with `npm`
1120

12-
## Installing
21+
## Check prerequisites
1322

14-
To install the dependencies:
23+
```bash
24+
make check
1525
```
26+
27+
## Installation
28+
29+
```bash
1630
make install
1731
```
1832

19-
## Starting LocalStack
33+
## Start LocalStack
2034

21-
Make sure that LocalStack is started:
22-
```
23-
LOCALSTACK_AUTH_TOKEN=... DEBUG=1 localstack start
35+
```bash
36+
export LOCALSTACK_AUTH_TOKEN=<your-auth-token>
37+
make start
2438
```
2539

26-
## Running
40+
## Run the application
2741

28-
Start the app locally and run the Athena test queries:
29-
```
42+
```bash
3043
make run
3144
```
3245

33-
The demo script performs the following actions:
46+
The script:
47+
48+
- Creates an S3 bucket and uploads CSV test data (person details) to the bucket.
49+
- Runs queries to create Athena database and table metadata.
50+
- Executes a SELECT query to count users by gender.
51+
- Downloads and displays the query results from the S3 results bucket.
3452

35-
1. Create an S3 bucket and upload test data (CSV files with person details) to the bucket
36-
2. Run queries to create the table metadata in Athena
37-
3. Running a simple query over the test file - querying the number of users by gender (male/female)
38-
4. Downloading the query results from the S3 results bucket
53+
You should see output similar to:
3954

40-
You should see something similar to the following log output in the terminal:
4155
```
4256
$ ./run.sh
4357
Uploading test data to S3...
@@ -46,8 +60,6 @@ upload: data/data.csv to s3://athena-test/data/data.csv
4660
Running queries to create database and table definitions...
4761
NOTE: This can take a very long time (several minutes) as the system is initializing
4862
Waiting for completion status of query cda0572a: RUNNING
49-
Waiting for completion status of query cda0572a: RUNNING
50-
Waiting for completion status of query cda0572a: RUNNING
5163
...
5264
Waiting for completion status of query cda0572a: SUCCEEDED
5365
Starting SELECT query over data in S3. Query ID: 8a19e3a3

0 commit comments

Comments
 (0)