I actually just got it running with DynamoDB subbing in for S3 pretty quickly. After setting up the table and adding this code to replace the former GetS3File()/UpdateS3File(), basically copying from the AWS basic tutorial examples:
Code:
func GetDynamoFile(table, filename string) (string, error) {
sess := getSession()
db := dynamodb.New(sess)
out, err := db.GetItem(&dynamodb.GetItemInput{
TableName: aws.String(table),
Key: map[string]*dynamodb.AttributeValue{
"id": {
S: aws.String(filename),
},
},
})
if err != nil {
return "", err
}
var file dynamoFile
err = dynamodbattribute.UnmarshalMap(out.Item, &file)
if err != nil {
return "", err
}
if file.Id == "" {
return "", fmt.Errorf("id not found: %s", filename)
}
return file.Data, nil
}
func UpdateDynamoFile(table, filename, content string) error {
sess := getSession()
db := dynamodb.New(sess)
file := dynamoFile{
Id: filename,
Data: content,
}
item, err := dynamodbattribute.MarshalMap(file)
if err != nil {
return err
}
input := &dynamodb.PutItemInput{
Item: item,
TableName: aws.String(table),
}
_, err = db.PutItem(input)
return err
}
...it just worked!