aws-ios-sdkから AWSS3TransferManager を使用して、iOS から s3 に写真をアップロードしようとしています。
boto3 を使用して Django バックエンドでGetOpenIdTokenForDeveloperIdentityを呼び出し、返されたトークンを iOS に渡すことで、AWS cognito Developer Authenticated Identitiesを使用しています。「AWSAbstractIdentityProvider」から継承する ID プロバイダーを実装し、self.token フィールドと self.identityID フィールドを設定してから、開発したインスタンス化されたプロバイダーを「credentialsProvider」パラメーターに渡します。
資格情報プロバイダーは、作成した ID プロバイダーで次のようにインスタンス化されます。
AWSCognitoCredentialsProvider *provider = [[AWSCognitoCredentialsProvider alloc]
initWithRegionType:AWSRegionUSEast1
identityProvider:self
unauthRoleArn:CognitoRoleUnauth
authRoleArn:CognitoRoleAuth];
CognitoRoleAuth は、以下に示すアクセス許可で作成した IAM ロールの arn です。すぐ下は構成のインスタンス化です。
AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 credentialsProvider:credentialsProvider];
次に、作成した構成を使用して、次のコードで「AWSS3TransferManager」オブジェクトをインスタンス化します。
`AWSServiceConfiguration *configuration = [appDelegate getConfig];
AWSS3TransferManager *transMan = [[AWSS3TransferManager new] initWithConfiguration:configuration identifier:@"poster"];`
Amazon Cognito で ID プールを作成し、次のアクセス許可で提案されているようにロールを作成しました。
{
"Version": "2012-10-17",
"Statement": [{
"Action": [
"mobileanalytics:PutEvents",
"cognito-sync:*"
],
"Effect": "Allow",
"Resource": [
"*"
]
},
{
"Sid": "Stmt15426553753",
"Action": [
"s3:AbortMultipartUpload",
"s3:DeleteObject",
"s3:GetObject",
"s3:PutObject"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::pics/auth"
}
]}
また、次の信頼関係があります。
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Federated": "cognito-identity.amazonaws.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"cognito-identity.amazonaws.com:aud": "us-east-1:identityPoolID"
},
"ForAnyValue:StringLike": {
"cognito-identity.amazonaws.com:amr": "authenticated"
}
}
}
]
}
転送マネージャーで「アップロード」を呼び出そうとするたびに、次のエラー メッセージが表示されます。
「sts:AssumeRoleWithWebIdentity を実行する権限がありません」
何を間違えたのかはわかりませんが、信頼関係に関係があるのかもしれません。助言がありますか?助けてください!