Skip to content

Instantly share code, notes, and snippets.

@deangiberson
Last active February 11, 2018 07:48
Show Gist options
  • Save deangiberson/c7de4202e588f5591514ef3872da9b38 to your computer and use it in GitHub Desktop.
Save deangiberson/c7de4202e588f5591514ef3872da9b38 to your computer and use it in GitHub Desktop.
dynamodb.deleteTable({
TableName: 'record'
})
dynamodb.createTable({
TableName: 'record',
AttributeDefinitions: [
{ AttributeName: 'name', AttributeType: 'S' },
{ AttributeName: 'part', AttributeType: 'N' }
],
KeySchema: [
{ AttributeName: 'name', KeyType: 'HASH' },
{ AttributeName: 'part', KeyType: 'RANGE' }
],
StreamSpecification: {
StreamEnabled: true,
StreamViewType: 'NEW_AND_OLD_IMAGES'
},
ProvisionedThroughput: {
ReadCapacityUnits: 5,
WriteCapacityUnits: 5
}
}, function (err, data) {
if (err) {
console.log(err, err.stack)
} else {
// data.TableDescription.StreamSpecification and
// data.TableDescription.LatestStreamArn are undefined
// for dynamodb local
console.log(data)
}
})
dynamodb.putItem({
TableName: 'record',
Item: {
'name': {S:'9094bea143d57c048517acd03a052f1ed3b7a46403a510529c900c31c02b7234'},
'part': 0,
'filesize':100
}
})
dynamodb.putItem({
TableName: 'record',
Item: {
'name': {S:'7e973cfb28619aa8aad470ec077f9da92e7b284f002fb9bbfe4f0352345a7f72'},
'part': 0,
'filesize':9833
}
})
aws --endpoint-url=http://localhost:4569 dynamodb create-table \
--table-name MusicCollection \
--attribute-definitions \
AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S \
--key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE \
--provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 \
--stream-specification StreamEnabled=true,StreamViewType=NEW_IMAGE
{
"TableDescription": {
"TableArn": "arn:aws:dynamodb:us-east-1:000000000000:table/MusicCollection",
"AttributeDefinitions": [
{
"AttributeName": "Artist",
"AttributeType": "S"
},
{
"AttributeName": "SongTitle",
"AttributeType": "S"
}
],
"ProvisionedThroughput": {
"NumberOfDecreasesToday": 0,
"WriteCapacityUnits": 1,
"LastIncreaseDateTime": 0.0,
"ReadCapacityUnits": 1,
"LastDecreaseDateTime": 0.0
},
"TableSizeBytes": 0,
"TableName": "MusicCollection",
"TableStatus": "ACTIVE",
"StreamSpecification": {
"StreamViewType": "NEW_IMAGE",
"StreamEnabled": true
},
"LatestStreamLabel": "2018-02-11T07:37:26.489",
"KeySchema": [
{
"KeyType": "HASH",
"AttributeName": "Artist"
},
{
"KeyType": "RANGE",
"AttributeName": "SongTitle"
}
],
"ItemCount": 0,
"CreationDateTime": 1518334646.489,
"LatestStreamArn": "arn:aws:dynamodb:ddblocal:000000000000:table/MusicCollection/stream/2018-02-11T07:37:26.489"
}
}
aws --endpoint-url=http://localhost:4569 dynamodb put-item --table-name MusicCollection --item '{"Artist":{"S":"Prince"},"SongTitle":{"S":"Purple Rain"}}'
aws --endpoint-url=http://localhost:4569 dynamodb put-item --table-name MusicCollection --item '{"Artist":{"S":"Michael Jackson"},"SongTitle":{"S":"Thriller"}}'
aws --endpoint-url=http://localhost:4570 dynamodbstreams list-streams
{
"LastEvaluatedStreamArn": "TODO",
"Streams": [
{
"TableName": "MusicCollection",
"StreamArn": "arn:aws:dynamodb:us-east-1:000000000000:table/MusicCollection/stream/2018-02-11T07:37:31",
"StreamLabel": "TODO"
}
]
}
aws --endpoint-url=http://localhost:4570 dynamodbstreams describe-stream --stream-arn 'arn:aws:dynamodb:us-east-1:000000000000:table/MusicCollection/stream/2018-02-11T07:37:31'
{
"StreamDescription": {
"StreamLabel": "TODO",
"StreamStatus": "ENABLED",
"TableName": "MusicCollection",
"Shards": [
{
"ShardId": "shardId-000000000000-eb21f0a24fbc56c3b158dc6ce671cff7",
"SequenceNumberRange": {
"StartingSequenceNumber": "49581617212059574715638333611478467498608671416469422082"
}
}
],
"StreamArn": "arn:aws:dynamodb:us-east-1:000000000000:table/MusicCollection/stream/2018-02-11T07:37:31",
"KeySchema": [
{
"KeyType": "HASH",
"AttributeName": "Artist"
},
{
"KeyType": "RANGE",
"AttributeName": "SongTitle"
}
]
}
}
aws --endpoint-url=http://localhost:4570 dynamodbstreams get-shard-iterator --stream-arn 'arn:aws:dynamodb:us-east-1:000000000000:table/MusicCollection/stream/2018-02-11T07:37:31' --shard-id 'shardId-000000000000-eb21f0a24fbc56c3b158dc6ce671cff7' --shard-iterator-type LATEST
{
"ShardIterator": "AAAAAAAAAAEOhUv0GXFAqoHrk1Rmrmh/8VC9ILQdibGsw+FQPIofLaumS3JgKsyE8JjfIPcC1JHQ85QLDKWqsj9QPeV05aGAb7I2NEzVAewSrUVAF7TUeVWwh8F5WMORIB0lbo1yEuWP7npkhkiAffZw1wLqfp8qfB0qmD4JQt1GKLo3yoAJ+ohHwNSaNm7UOy9oz1vdxjrHH9+qMQRjpXfwXB9EYXhb"
}
aws --endpoint-url=http://localhost:4570 dynamodbstreams get-records --shard-iterator 'AAAAAAAAAAEOhUv0GXFAqoHrk1Rmrmh/8VC9ILQdibGsw+FQPIofLaumS3JgKsyE8JjfIPcC1JHQ85QLDKWqsj9QPeV05aGAb7I2NEzVAewSrUVAF7TUeVWwh8F5WMORIB0lbo1yEuWP7npkhkiAffZw1wLqfp8qfB0qmD4JQt1GKLo3yoAJ+ohHwNSaNm7UOy9oz1vdxjrHH9+qMQRjpXfwXB9EYXhb'
{
"Records": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment