I’m testing out backing Core Data onto DynamoDB and I have implemented AWSPersistenceDynamoDBIncrementalStoreDelegate on my app delegate, with the pertinent credentials method implemented as such:
- (AmazonCredentials *)credentials
{
if(credentials==nil) {
credentials = [[AmazonCredentials alloc] initWithAccessKey:@"ACCESS_KEY" withSecretKey:@"SECRET_KEY"];
}
return credentials;
}
obviously substituting my real security credentials as appropriate (this isn’t how it would be implemented for production, but I don’t want to setup a TVM for the prototyping I’m doing).
However, when I attempt to create an Entity as such:
Track *track = (Track*)[NSEntityDescription insertNewObjectForEntityForName:@"Track" inManagedObjectContext:appDelegate.managedObjectContext];
I get the following error:
error: Error Domain=com.amazonaws.coredata.AWSPersistenceDynamoDBClientErrorDomain Code=-1 "The operation couldn’t be completed. (com.amazonaws.coredata.AWSPersistenceDynamoDBClientErrorDomain error -1.)" UserInfo=0xa5363d0 {message=The protocol - (AmazonCredentials *)credentials didn't return a valid AmazonCredentials object.}
I can see that the AmazonCredentials object is instantiated and has the correct details and I can use the same credentials to establish an AmazonS3Client session and download files from a bucket, so they are definitely valid.
Has anyone seen this / know what the problem is?
Ok, looking at the code on Github https://github.com/aws/aws-sdk-ios/blob/master/src-persistence/AWSPersistenceDynamoDBIncrementalStore.m it shows that you have to use the three arg constructor including a security token to use DynamoDB to back Core Data, would be useful if in mentioned that in the docs, but anyway, in short you have to implement a TVM to be able to do this.