Skip to content

Commit

Permalink
Simplify development and debugging with ./scripts/(re)deploy.sh and .…
Browse files Browse the repository at this point in the history
…/scripts/logs.sh, making those scripts fully idempotent and easy to use
  • Loading branch information
brainstorm committed Nov 29, 2023
1 parent da57062 commit 74fdb4e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 95 deletions.
33 changes: 2 additions & 31 deletions lib/workload/stateful/filemanager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ docker compose up
Then deploy the cdk to localstack:

```sh
cd deploy
npm install
npx cdklocal bootstrap
npx cdklocal deploy
./scripts deploy.sh
```

It's possible that a profile called "default" in `~/.aws/config` could interfere with awslocal. A recommended `~/.aws/credentials` that works with localstack's dummy `0000000000` AWS account would look like this:
Expand All @@ -84,35 +81,9 @@ aws_access_key_id = access_key
aws_secret_access_key = secret_key
```

Make sure there's no pre-existing deployment with `npx cdklocal destroy`, otherwise your stack might fail to deploy with `CREATE FAILED`.
Also, `cargo install sqlx-cli` tools to easy database migration helpers and perform migrations when needed:

```shell
cd database && sqlx migrate run
```

## Ingestion test

This allows creating synthetic events that are ingested and stored in filemanager's database.

Here it is assumed that [`awslocal`](https://github.com/localstack/awscli-local) has been installed beforehand.

First, push an object (in order to create a log group):

```sh
awslocal s3 mb s3://filemanager-test-ingest
awslocal s3api put-object --bucket filemanager-test-ingest --key test
```

Then in a separate terminal:

```sh
./deploy/aws-get-filemanager-logs.sh -c awslocal
```

## Database

A shortcut for connecting to the docker database:
A shortcut for connecting to the docker database and inspecting its contents:

```bash
docker exec -it filemanager_db psql filemanager -U filemanager
Expand Down

This file was deleted.

This file was deleted.

15 changes: 15 additions & 0 deletions lib/workload/stateful/filemanager/scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh -x

export AWS_ENDPOINT_URL=http://localhost:4566
export FM_BUCKET=filemanager-test-ingest

cd deploy
yes | npx cdklocal destroy
yes | npx cdklocal bootstrap
yes | npx cdklocal deploy
cd ../database && sqlx migrate run && cd ..

aws s3 mb s3://$FM_BUCKET
aws s3api put-object --bucket $FM_BUCKET --key test

./scripts/logs.sh
6 changes: 6 additions & 0 deletions lib/workload/stateful/filemanager/scripts/logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

export AWS_ENDPOINT_URL=http://localhost:4566

group_name=$(aws logs describe-log-groups --query 'logGroups[*].logGroupName' --output text)
aws logs tail "$group_name" --follow

0 comments on commit 74fdb4e

Please sign in to comment.