Skip to content

Instantly share code, notes, and snippets.

@nbenns
Created November 3, 2017 04:03
Show Gist options
  • Save nbenns/1b20b39a51b8d7f614913a38273f0d3c to your computer and use it in GitHub Desktop.
Save nbenns/1b20b39a51b8d7f614913a38273f0d3c to your computer and use it in GitHub Desktop.
import com.amazonaws.auth.{AWSStaticCredentialsProvider, BasicAWSCredentials}
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder
import com.amazonaws.services.dynamodbv2.model._
import com.amazonaws.services.dynamodbv2.model.ScalarAttributeType._
import scala.collection.convert.decorateAsJava._
val credentials = new BasicAWSCredentials("dev", "dev")
val credProvider = new AWSStaticCredentialsProvider(credentials)
val endpointConfiguration = new EndpointConfiguration("http://localhost:8000", "local")
val tableName = "profile-table"
val client =
AmazonDynamoDBClientBuilder.standard()
.withCredentials(credProvider)
.withEndpointConfiguration(endpointConfiguration)
.build()
val keySchemas = List(
new KeySchemaElement("id", KeyType.HASH)
).asJava
val attibutedefs = List(
new AttributeDefinition("id", S)
).asJava
client.createTable(attibutedefs, tableName, keySchemas, new ProvisionedThroughput(1L, 1L))
//client.deleteTable(tableName)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment