-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset_up_dynamodb.py
43 lines (38 loc) · 966 Bytes
/
set_up_dynamodb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
import boto3
# create a boto3 session (should load your stored credentials automatically)
session = boto3.Session()
# create a client for interacting with dynamodb
dynamodb = session.resource('dynamodb')
table = dynamodb.create_table(
TableName=os.environ['DYNAMO_DB_RESULTS_TABLE'],
KeySchema=[
{
'AttributeName': 'race_type',
'KeyType': 'HASH'
},
{
'AttributeName': 'last_updated',
'KeyType': 'RANGE'
}
],
AttributeDefinitions=[
{
'AttributeName': 'race_type',
'AttributeType': 'S'
},
{
'AttributeName': 'last_updated',
'AttributeType': 'N'
},
],
ProvisionedThroughput={
'ReadCapacityUnits': 20,
'WriteCapacityUnits': 5,
}
)
table.meta.client.get_waiter(
'table_exists'
).wait(
TableName=os.environ['DYNAMO_DB_RESULTS_TABLE']
)