Skip to content

Commit

Permalink
Merge pull request release-engineering#405 from rohanpm/dev-config-table
Browse files Browse the repository at this point in the history
dev env: update scripts/instructions for config table
  • Loading branch information
rohanpm authored Feb 15, 2022
2 parents e2f63b1 + 8caed70 commit aaa0770
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 20 deletions.
25 changes: 8 additions & 17 deletions docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,27 +182,18 @@ the development environment.

- Other parameters can be omitted.

* - ``scripts/localstack-s3-init``
* - ``scripts/localstack-init``

``scripts/localstack-s3-init some-bucket``

- Create a bucket in localstack.
- Create resources in localstack.

The localstack environment is initially empty, which will make it impossible to
upload any objects. For upload to work with exodus-gw, you'll want to create one
or more buckets matching the info in ``exodus-gw.ini``. The script will make a bucket
matching the ``test`` environment if no name is specified.

* - ``scripts/localstack-dynamodb-init``

``scripts/localstack-dynamodb-init some-table``
upload any objects. For upload to work with exodus-gw, you'll want to create buckets
and DynamoDB tables matching the info in ``exodus-gw.ini``. This script will create
those resources.

- Create a table in localstack.

The localstack environment is initially empty, which will make it impossible to
execute any publish tasks. For publish to work with exodus-gw, you'll want to create
one or more tables matching the info in ``exodus-gw.ini``. The script will make a table
matching the ``test`` environment if no name is specified.
The script uses defaults which are only appropriate for the ``test`` environment
defined in the repo's ``exodus-gw.ini``. Check the other ``localstack-*-init``
scripts if you need to create buckets/tables with other names.

* - ``aws --endpoint-url=https://localhost:3377 s3 ls s3://my-bucket``
- List files in localstack s3 bucket.
Expand Down
3 changes: 1 addition & 2 deletions scripts/launch-devenv
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ setup_certs(){
}

init_aws_infra(){
scripts/localstack-s3-init
scripts/localstack-dynamodb-init
scripts/localstack-init
}

run(){
Expand Down
31 changes: 31 additions & 0 deletions scripts/localstack-dynamodb-config-init
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh
#
# Create a dynamodb table for config in the dev env's localstack instance.
#
# You will need to run this when:
# - initially creating the dev env, or
# - after cleaning it, or
# - if you want to use a different table
#

# should match table for the environment you want to use in exodus-gw.ini
TABLE_NAME="${1:-my-config}"

ENV_FILE="~/.config/exodus-gw-dev/.env"

if test -f "$ENV_FILE"; then
. "$ENV_FILE"
fi

set -xe

exec aws \
--endpoint-url="${EXODUS_GW_DYNAMODB_ENDPOINT_URL:-https://localhost:3377}" \
dynamodb \
create-table \
--table-name "${TABLE_NAME}" \
--attribute-definitions AttributeName=config_id,AttributeType=S \
AttributeName=from_date,AttributeType=S \
--key-schema AttributeName=config_id,KeyType=HASH \
AttributeName=from_date,KeyType=RANGE \
--provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=10
2 changes: 1 addition & 1 deletion scripts/localstack-dynamodb-init
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# Create a dynamodb table in the dev env's localstack instance.
# Create a dynamodb table for content in the dev env's localstack instance.
#
# You will need to run this when:
# - initially creating the dev env, or
Expand Down
21 changes: 21 additions & 0 deletions scripts/localstack-init
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
#
# Populate localstack with basic resources needed for exodus-gw to run.
#
# This script accepts no arguments and is only usable for the default
# config in exodus-gw.ini. If you want to deploy different buckets/tables,
# invoke the localstack-*-init scripts separately.
#
# You will need to run this when:
# - initially creating the dev env, or
# - after cleaning it
#
thisdir=$(dirname $0)

# Note: we continue on error here because the DDB steps will complain if
# tables already exist, which is inconvenient
set -x

$thisdir/localstack-s3-init
$thisdir/localstack-dynamodb-init
$thisdir/localstack-dynamodb-config-init

0 comments on commit aaa0770

Please sign in to comment.