Scylla Documentation Logo Documentation
  • Server
    • Scylla Open Source
    • Scylla Enterprise
    • Scylla Alternator
  • Cloud
    • Scylla Cloud
    • Scylla Cloud Docs
  • Tools
    • Scylla Manager
    • Scylla Monitoring Stack
    • Scylla Operator
  • Drivers
    • CQL Drivers
    • DynamoDB Drivers
Download
Menu
Scylla Dev Alternator: DynamoDB API in Scylla Getting Started With ScyllaDB Alternator

Getting Started With ScyllaDB Alternator¶

Installing Scylla¶

Before you can start using ScyllaDB Alternator, you will have to have an up and running scylla cluster configured to expose the alternator port. This section will guide you through the steps for setting up the cluster:

Get Scylla with alternator support from a docker:¶

  1. Because Alternator is still improving quickly, it is recommended to run the latest nightly build. Make sure you have the latest nightly image by running: docker pull scylladb/scylla-nightly:latest

  2. Follow the steps in the Scylla official download web page add to every “docker run” command: -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 Scylla 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-nightly: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.

Testing Scylla’s DynamoDB API support:¶

Running AWS Tic Tac Toe demo app to test the cluster:¶

  1. Follow the instructions on the AWS github page

  2. Enjoy your tic-tac-toe game :-)

Setting up the python environment¶

Run the following commands on your machine, this will install boto3 python library which also contains drivers for DynamoDB:

sudo pip install --upgrade boto3

Running some simple scripts:¶

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.

  1. Put the following create table example script in a python file and run it (changing local host to the address of your docker node if you are using docker):

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'
    },
    ])
  1. Put the following write example script in a python file and run it (changing local host to the address of your docker node if you are using docker):

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'}
                 }
             },
        }
    ]
})
  1. Put the following read example script in a python file and run it (changing local host to the address of your docker node if you are using docker):

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.

PREVIOUS
Alternator: DynamoDB API in Scylla
NEXT
Scylla Alternator for DynamoDB users
  • 4.6
    • 4.6
    • 4.5
  • Scylla Developer Documentation
  • Alternator: DynamoDB API in Scylla
    • Getting Started With ScyllaDB Alternator
    • Scylla Alternator for DynamoDB users
  • Design Notes
    • IDL compiler
    • CDC
    • The Compaction Controller
    • Scylla CQL extensions
    • Scylla CQL extensions
    • CQL3 Type Mapping
    • Hinted Handoff Design
    • Performance Isolation in Scylla
    • CQL to Lua type mapping
    • Scylla Metrics
    • Migrating from users to roles
    • Paged queries
    • Protocol extensions to the Cassandra Native Protocol
    • Ports and protocols in Scylla
    • Redis API in Scylla
    • Repair based node operations
    • Reverse reads
    • Row Cache
    • Row level repair
    • Secondary indexes in Scylla
    • File format of the Scylla.db sstable component
    • sstables directory structure
    • System keyspace layout
    • System schema keyspace layout
    • WASM support for user-defined functions
  • Guides
    • Guidelines for developing Scylla
    • Scylla RESTful API V2
    • Building Scylla
    • Debugging with GDB
    • Docker Hub Image
    • Logging in Scylla
    • Testing
    • Tracing
  • Contribute
    • Contributing to Scylla
    • Backport
    • Maintainer’s handbook
    • Review Checklist
  • Service Level Distributed Data
  • Create an issue
  • Edit this page

On this page

  • Getting Started With ScyllaDB Alternator
    • Installing Scylla
      • Get Scylla with alternator support from a docker:
    • Testing Scylla’s DynamoDB API support:
      • Running AWS Tic Tac Toe demo app to test the cluster:
      • Setting up the python environment
      • Running some simple scripts:
Logo
Docs Contact Us About Us
Mail List Icon Slack Icon
© 2022, ScyllaDB. All rights reserved.
Last updated on 12 May 2022.
Powered by Sphinx 4.3.2 & ScyllaDB Theme 1.2.1