I am trying to use DynamoDB using the iOS Swift SDK. I use Cognito with Facebook as an external identity provider. Cognito works fine - I checked user synchronization and it works fine, so I believe that I have authentication installed. This is how I configure the SDK (I have the actual values ββof my identifier pool in my code):
let credentialsProvider = AWSCognitoCredentialsProvider(regionType:.USEast1, identityPoolId:"<my-identity-pool-id>", identityProviderManager: FacebookProvider()) let configuration = AWSServiceConfiguration(region:.USEast1, credentialsProvider:credentialsProvider) AWSServiceManager.default().defaultServiceConfiguration = configuration
And here is my DynamoDB class mapped:
import Foundation import AWSDynamoDB class SavedItem : AWSDynamoDBObjectModel, AWSDynamoDBModeling { var userId : Int? var timestamp : Int? class func dynamoDBTableName() -> String { return "my-table" } class func hashKeyAttribute() -> String { return "userId" } class func rangeKeyAttribute() -> String { return "timestamp" } }
I verified that my code has the correct table and attribute names and that the hash and range key values ββin the table are identical, including case sensitivity, with the fields in my SavedItem class.
This is how I create the mapper instance:
let dynamoDBObjectMapper = AWSDynamoDBObjectMapper.default() let savedItem = SavedItem() savedItem?.userId = 1 savedItem?.timestamp = 2 dynamoDBObjectMapper.save(savedItem!).continueWith(block: { (task:AWSTask<AnyObject>!) -> Any? in if let error = task.error as? NSError { print("The request failed. Error: \(error)") } else { print("Save callback executing") } return nil })
This code is more or less directly from the AWS sample documentation. But here is what I will return to the console when this code executes:
Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=0 "(null)" UserInfo={__type=com.amazon.coral.validate
I ran into console logging before debugging, and it looks like it is not sending any attributes from the SavedItem object. Here's what in the console for the save request body:
Request body: {"Key":{"userId":{},"timestamp":{}},"TableName":"my-table","AttributeUpdates":{}}
Any idea why the values ββdo not fall into the body of the save request?
Using aws-sdk-ios v2.6.1 in Swift 4 on iOS 11.