Skip to content

Commit c363f7e

Browse files
authored
Add LocalStack auth token requirement and standardize setup (#5)
- Add license requirement bullet to Prerequisites - Create Makefile with start/stop/ready/logs targets and auth guard - Add Start LocalStack section to README - Upgrade actions/checkout, setup-node, upload-artifact to v4 - Replace LOCALSTACK_API_KEY with LOCALSTACK_AUTH_TOKEN
1 parent c3f22d3 commit c363f7e

3 files changed

Lines changed: 44 additions & 7 deletions

File tree

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- name: Checkout
24-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
2525

2626
- uses: gautamkrishnar/keepalive-workflow@v1
2727

2828
- name: Setup Node.js
29-
uses: actions/setup-node@v3
29+
uses: actions/setup-node@v4
3030
with:
3131
node-version: 20
3232

@@ -46,7 +46,7 @@ jobs:
4646
4747
- name: Start LocalStack
4848
env:
49-
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
49+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
5050
run: |
5151
pip install localstack awscli-local[ver1]
5252
docker pull localstack/localstack-pro:latest
@@ -90,7 +90,7 @@ jobs:
9090
9191
- name: Upload the Diagnostic Report
9292
if: failure()
93-
uses: actions/upload-artifact@v3
93+
uses: actions/upload-artifact@v4
9494
with:
9595
name: diagnose.json.gz
9696
path: ./diagnose.json.gz

Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
export AWS_ACCESS_KEY_ID ?= test
2+
export AWS_SECRET_ACCESS_KEY ?= test
3+
export AWS_DEFAULT_REGION=us-east-1
4+
SHELL := /bin/bash
5+
6+
usage: ## Show this help
7+
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$//' | sed -e 's/##//'
8+
9+
install: ## Install dependencies
10+
@which localstack || pip install localstack
11+
@which awslocal || pip install awscli-local
12+
@which cdklocal || npm install -g aws-cdk-local aws-cdk
13+
14+
start: ## Start LocalStack
15+
@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)
16+
@LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) localstack start -d
17+
18+
stop: ## Stop LocalStack
19+
@localstack stop
20+
21+
ready: ## Wait until LocalStack is ready
22+
@echo Waiting on the LocalStack container...
23+
@localstack wait -t 30 && echo LocalStack is ready to use! || (echo Gave up waiting on LocalStack, exiting. && exit 1)
24+
25+
logs: ## Save the logs in a separate file
26+
@localstack logs > logs.txt
27+
28+
deploy: ## Deploy infrastructure using CDK
29+
pip install -r requirements.txt
30+
cdklocal bootstrap
31+
cdklocal deploy --require-approval never
32+
33+
.PHONY: usage install start stop ready logs deploy

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,21 @@ We are using the following AWS services and their features to build our infrastr
3535

3636
## Prerequisites
3737

38-
- LocalStack Pro with the [`localstack` CLI](https://docs.localstack.cloud/getting-started/installation/#localstack-cli).
38+
- 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.
39+
- [`localstack` CLI](https://docs.localstack.cloud/getting-started/installation/#localstack-cli).
3940
- [Cloud Development Kit (CDK)](https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html) installed with the [`cdklocal` wrapper](https://docs.localstack.cloud/user-guide/integrations/aws-cdk/).
4041
- [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).
4142
- [Node.js](https://nodejs.org/en/) with the `npm` package manager.
4243
- [Python 3.8.0](https://www.python.org/downloads/release/python-380/) in the `PATH`
4344

44-
Start LocalStack Pro with the `LOCALSTACK_AUTH_TOKEN` pre-configured:
45+
## Start LocalStack
46+
47+
Start LocalStack with the `LOCALSTACK_AUTH_TOKEN` pre-configured:
4548

4649
```shell
4750
export LOCALSTACK_AUTH_TOKEN=<your-auth-token>
48-
DEBUG=1 localstack start
51+
make start
52+
make ready
4953
```
5054

5155
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.

0 commit comments

Comments
 (0)