docs/alternator/getting-started.md
Before you can start using ScyllaDB Alternator, you will have to have an up and running a ScyllaDB cluster configured to expose the Alternator port. This section will guide you through the steps for setting up the cluster:
docker pull scylladb/scylla:latestdocker run
command a -p 8000:8000 before the image name and
--alternator-port=8000 --alternator-write-isolation=always at the end.
The "alternator-port" option specifies on which port ScyllaDB will listen for
the (unencrypted) DynamoDB API, and the "alternator-write-isolation" chooses
whether or not Alternator will use LWT for every write.
For example,
docker run --name scylla -d -p 8000:8000 scylladb/scylla:latest --alternator-port=8000 --alternator-write-isolation=always.
The --alternator-https-port=... option can also be used to enable
Alternator on an encrypted (HTTPS) port. Note that in this case, the files
/etc/scylla/scylla.crt and /etc/scylla/scylla.key must be inserted into
the image, containing the SSL certificate and key to use.By default, ScyllaDB run in this way will not have authentication or authorization enabled, and any DynamoDB API request will be honored without requiring them to be signed appropriately. See the ScyllaDB Alternator for DynamoDB users document on how to configure authentication and authorization.
Run the following commands on your machine, this will install boto3 python library which also contains drivers for DynamoDB:
sudo pip install --upgrade boto3
The following is a 3 scripts test that creates a table named usertable writes the famous hello world record to it, and then, reads it back.
import boto3
dynamodb = boto3.resource('dynamodb',endpoint_url='http://localhost:8000',
region_name='None', aws_access_key_id='None', aws_secret_access_key='None')
dynamodb.create_table(
AttributeDefinitions=[
{
'AttributeName': 'key',
'AttributeType': 'S'
},
],
BillingMode='PAY_PER_REQUEST',
TableName='usertable',
KeySchema=[
{
'AttributeName': 'key',
'KeyType': 'HASH'
},
])
import boto3
dynamodb = boto3.resource('dynamodb',endpoint_url='http://localhost:8000',
region_name='None', aws_access_key_id='None', aws_secret_access_key='None')
dynamodb.batch_write_item(RequestItems={
'usertable': [
{
'PutRequest': {
'Item': {
'key': 'test', 'x' : {'hello': 'world'}
}
},
}
]
})
import boto3
dynamodb = boto3.resource('dynamodb',endpoint_url='http://localhost:8000',
region_name='None', aws_access_key_id='None', aws_secret_access_key='None')
print(dynamodb.batch_get_item(RequestItems={
'usertable' : { 'Keys': [{ 'key': 'test' }] }
}))
You should see the record you inserted in step 2 along with some http info printed to screen.