Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Create PR Preview

on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened]

Expand All @@ -22,18 +23,17 @@ jobs:
state-backend: ephemeral
state-action: start
include-preview: 'true'
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;

16 changes: 5 additions & 11 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

## export configs for web app
prepare-frontend-local:
Expand All @@ -50,16 +49,11 @@ deploy-frontend:
## Stop the Running LocalStack container
stop:
@echo
localstack 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 stop

## 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 All @@ -69,4 +63,4 @@ setup-challenge:
make prepare-frontend-local
make hotreload

.PHONY: usage install run start stop ready logs
.PHONY: usage install run start stop logs
12 changes: 6 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. `lstk` always runs the emulator in detached mode; use `lstk logs` or Docker Desktop to view the logs.

## Instructions

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