github.com/thiagoyeds/go-cloud@v0.26.0/docstore/awsdynamodb/create_tables.sh (about)

     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    --table-name docstore-test-1 \
    31    --attribute-definitions AttributeName=name,AttributeType=S \
    32    --key-schema AttributeName=name,KeyType=HASH \
    33    --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
    34  
    35  
    36  # The docstore-test-2 table has both a partition and a sort key, and two indexes.
    37  
    38  aws dynamodb create-table \
    39    --table-name docstore-test-2 \
    40    --attribute-definitions \
    41          AttributeName=Game,AttributeType=S \
    42          AttributeName=Player,AttributeType=S \
    43          AttributeName=Score,AttributeType=N \
    44          AttributeName=Time,AttributeType=S \
    45    --key-schema AttributeName=Game,KeyType=HASH AttributeName=Player,KeyType=RANGE \
    46    --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \
    47    --local-secondary-indexes \
    48    'IndexName=local,KeySchema=[{AttributeName=Game,KeyType=HASH},{AttributeName=Score,KeyType=RANGE}],Projection={ProjectionType=ALL}' \
    49    --global-secondary-indexes \
    50    'IndexName=global,KeySchema=[{AttributeName=Player,KeyType=HASH},{AttributeName=Time,KeyType=RANGE}],Projection={ProjectionType=ALL},ProvisionedThroughput={ReadCapacityUnits=5,WriteCapacityUnits=5}'
    51  
    52