| 1 |
#!/usr/bin/env bash |
| 2 |
# Copyright 2019 The Go Cloud Development Kit Authors |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
# you may not use this file except in compliance with the License. |
| 6 |
# You may obtain a copy of the License at |
| 7 |
# |
| 8 |
# https://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
# See the License for the specific language governing permissions and |
| 14 |
# limitations under the License. |
| 15 |
|
| 16 |
# Creates the DynamoDB tables needed for tests. |
| 17 |
# |
| 18 |
# If a table already exists, this script will fail. To re-create the table, run |
| 19 |
# aws dynamodb delete-table --table-name ... |
| 20 |
# and wait until the deletion completes. |
| 21 |
|
| 22 |
# https://coderwall.com/p/fkfaqq/safer-bash-scripts-with-set-euxo-pipefail |
| 23 |
# except we want to keep going if there is a failure. |
| 24 |
set -uxo pipefail |
| 25 |
|
| 26 |
# The docstore-test-1 table has a single partition key called "name". |
| 27 |
|
| 28 |
|
| 29 |
aws dynamodb create-table \ |
| 30 |
--region us-east-2 \ |
| 31 |
--table-name docstore-test-1 \ |
| 32 |
--attribute-definitions AttributeName=name,AttributeType=S \ |
| 33 |
--key-schema AttributeName=name,KeyType=HASH \ |
| 34 |
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 |
| 35 |
|
| 36 |
|
| 37 |
# The docstore-test-2 table has both a partition and a sort key, and two indexes. |
| 38 |
|
| 39 |
aws dynamodb create-table \ |
| 40 |
--region us-east-2 \ |
| 41 |
--table-name docstore-test-2 \ |
| 42 |
--attribute-definitions \ |
| 43 |
AttributeName=Game,AttributeType=S \ |
| 44 |
AttributeName=Player,AttributeType=S \ |
| 45 |
AttributeName=Score,AttributeType=N \ |
| 46 |
AttributeName=Time,AttributeType=S \ |
| 47 |
--key-schema AttributeName=Game,KeyType=HASH AttributeName=Player,KeyType=RANGE \ |
| 48 |
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \ |
| 49 |
--local-secondary-indexes \ |
| 50 |
'IndexName=local,KeySchema=[{AttributeName=Game,KeyType=HASH},{AttributeName=Score,KeyType=RANGE}],Projection={ProjectionType=ALL}' \ |
| 51 |
--global-secondary-indexes \ |
| 52 |
'IndexName=global,KeySchema=[{AttributeName=Player,KeyType=HASH},{AttributeName=Time,KeyType=RANGE}],Projection={ProjectionType=ALL},ProvisionedThroughput={ReadCapacityUnits=5,WriteCapacityUnits=5}' |
| 53 |
|
| 54 |
|