I followed the firsts steps here to configure credentials and an S3 bucket. Then, in my code, I have:
func setupCredentialsProvider() {
let credentialsProvider = AWSCognitoCredentialsProvider(regionType:.USEast1, identityPoolId:identityPoolIdStr)
let configuration = AWSServiceConfiguration(region:.USEast1, credentialsProvider:credentialsProvider)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration
AWSServiceConfiguration(region: AWSRegionType.USEast1, credentialsProvider: credentialsProvider)
}
func listObjects() {
let s3 = AWSS3.defaultS3()
let listObjectsRequest = AWSS3ListObjectsRequest()
listObjectsRequest.bucket = S3BucketName
s3.listObjects(listObjectsRequest).continueWithBlock { (task) -> AnyObject! in
if let error = task.error {
print("listObjects failed: [\(error)]")
}
if let exception = task.exception {
print("listObjects failed: [\(exception)]")
}
}
When I run the app and listObjects() is called, I get this error:
listObjects failed: [Error Domain=com.amazonaws.AWSServiceErrorDomain Code=11 "(null)" UserInfo={HostId=, Message=Access Denied, Code=AccessDenied, RequestId=}]
What am I missing?