Reputation: 23883
I'm using xcode 6.4 for my project. The problem is I got some issue regarding to AWS S3 (Amazon Web Services S3). What I need to do is download the file from the bucket. It said Identity pool id not found but already check it several of times, same exactly inside the console. I got this error message when trying to download the file.
2015-10-01 14:44:09.470 XXXXX[9842:360833] AWSiOSSDKv2 [Error] AWSIdentityProvider.m line:185 | __51-[AWSAbstractCognitoIdentityProvider getIdentityId]_block_invoke169 | GetId failed. Error is [Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=12 "The operation couldn’t be completed. (com.amazonaws.AWSCognitoIdentityErrorDomain error 12.)" UserInfo=0x7ff56b0f1260 {__type=ResourceNotFoundException, message=IdentityPool 'ap-northeast-1:a4ef1695-XXXX-4e7c-XXXX-56f2a09eXXXX' not found.}]
2015-10-01 14:44:09.471 XXXXX[9842:360833] AWSiOSSDKv2 [Error] AWSCredentialsProvider.m line:527 | __40-[AWSCognitoCredentialsProvider refresh]_block_invoke352 | Unable to refresh. Error is [Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=12 "The operation couldn’t be completed. (com.amazonaws.AWSCognitoIdentityErrorDomain error 12.)" UserInfo=0x7ff56b0f1260 {__type=ResourceNotFoundException, message=IdentityPool 'ap-northeast-1:a4ef1695-XXXX-4e7c-XXXX-56f2a09eXXXX' not found.}]
AppDelegate.swift
import UIKit
import CoreData
import AWSS3
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var cognitoIdentityPoolId: String = "ap-northeast-1:a4ef1695-XXXX-4e7c-XXXX-56f2a09eXXXX"
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
let credentialsProvider = AWSCognitoCredentialsProvider(regionType: AWSRegionType.APNortheast1, identityPoolId: cognitoIdentityPoolId)
let defaultServiceConfiguration = AWSServiceConfiguration(
region: AWSRegionType.APNortheast1, credentialsProvider: credentialsProvider)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = defaultServiceConfiguration
return true
}
/* -- */
}
ViewController.swift
import UIKit
import AWSS3
class ViewController: UIViewController{
let transferManager = AWSS3TransferManager.defaultS3TransferManager()
override func viewDidLoad() {
super.viewDidLoad()
var downloadingFilePath: NSString = NSTemporaryDirectory().stringByAppendingPathComponent("downloaded-myImage.gif")
var downloadingFileURL: NSURL = NSURL.fileURLWithPath(downloadingFilePath as String)!
var downloadRequest = AWSS3TransferManagerDownloadRequest()
downloadRequest.bucket = "xxxxxx-stg/events"
downloadRequest.key = "myImage.gif"
downloadRequest.downloadingFileURL = downloadingFileURL
transferManager.download(downloadRequest).continueWithSuccessBlock({
(task: AWSTask!) -> AWSTask! in
dispatch_async(dispatch_get_main_queue(), {
println("test")
})
return nil
})
}
}
Is it regarding to IAM Policy issue or need set custom Authentication Provider?
Reference: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html
Upvotes: 1
Views: 4533
Reputation: 104
I solved this by attaching the 'AmazonS3ReadOnlyAccess' policy to the IAM entity i was trying to use, including the Unauthenticated role. You can also attach the 'AmazonS3FullAccess' policy if that's okay for what you are building. These policies are found in the 'policies' tab of your IAM page.
Upvotes: 0
Reputation: 23883
I already got the answer. I update the IAM policy like this
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"mobileanalytics:PutEvents",
"cognito-sync:*"
],
"Resource": [
"*"
]
}
]
}
And allow Unauthenticated Access
.
Upvotes: 1
Reputation: 41
Make sure you have set your IAM Policy. It is under IAM -> Roles -> Inline Policy -> Edit Policy. It should look something similar to this:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"mobileanalytics:PutEvents",
"cognito-sync:*",
"s3:*"
],
"Resource": [
"*"
]
}
]
}
Upvotes: 3