Skip to content

Instantly share code, notes, and snippets.

@yusefnapora
Last active June 8, 2016 18:38
Show Gist options
  • Save yusefnapora/842312bc3e1be6c1e35c551c8864f6dc to your computer and use it in GitHub Desktop.
Save yusefnapora/842312bc3e1be6c1e35c551c8864f6dc to your computer and use it in GitHub Desktop.
setup local dynamo for mediachain
import com.amazonaws.auth.BasicAWSCredentials
val awscreds = new BasicAWSCredentials("", "")
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient
val dynamo = new AmazonDynamoDBClient(awscreds).withEndpoint("http://localhost:8000").asInstanceOf[AmazonDynamoDBClient]
import scala.collection.JavaConversions._
import com.amazonaws.services.dynamodbv2.model._
val baseTable = "Mediachain"
val chunkTable = baseTable + "Chunks"
val mainTableAttrs = List(new AttributeDefinition("multihash", "S"))
val mainTableSchema = List(new KeySchemaElement("multihash", KeyType.HASH))
val pth = new ProvisionedThroughput(10, 10)
dynamo.createTable(mainTableAttrs, baseTable, mainTableSchema, pth)
val chunkTableAttrs = List(new AttributeDefinition("chunkId", "S"))
val chunkTableSchema = List(new KeySchemaElement("chunkId", KeyType.HASH))
dynamo.createTable(chunkTableAttrs, chunkTable, chunkTableSchema, pth)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment