[英]NO_READ_ACCESS_TO_S3 while calling StartTextTranslationJob on AWS Translate
我正在嘗試使用以下 python 代碼對存儲在 S3 中的批處理數據運行 AWS Translate 作業
role_arn='arn:aws:iam::<account-id>:role/service-role/AmazonTranslateServiceRoleS3FullAccess-ExploreML'
inp_data_path='s3://exploring-ml/aws-translate/assets/input/'
opt_data_path='s3://exploring-ml/aws-translate/assets/output/'
response = translate_client.start_text_translation_job(
JobName='string',
InputDataConfig={
'S3Uri': inp_data_path,
'ContentType': 'text/plain'
},
OutputDataConfig={
'S3Uri': opt_data_path
},
DataAccessRoleArn=role_arn,
SourceLanguageCode='zh',
TargetLanguageCodes=[
'en'
]
)
我可以確認該角色具有完整的 S3 訪問權限,但是,在執行上述代碼時,出現以下錯誤
---------------------------------------------------------------------------
InvalidRequestException Traceback (most recent call last)
<ipython-input-11-2bf8de09e0fe> in <module>
11 SourceLanguageCode='zh',
12 TargetLanguageCodes=[
---> 13 'en'
14 ]
15 )
~/.local/share/virtualenvs/exploring-ml-tools-zug9J9gH/lib/python3.6/site-packages/botocore/client.py in _api_call(self, *args, **kwargs)
314 "%s() only accepts keyword arguments." % py_operation_name)
315 # The "self" in this scope is referring to the BaseClient.
--> 316 return self._make_api_call(operation_name, kwargs)
317
318 _api_call.__name__ = str(py_operation_name)
~/.local/share/virtualenvs/exploring-ml-tools-zug9J9gH/lib/python3.6/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params)
633 error_code = parsed_response.get("Error", {}).get("Code")
634 error_class = self.exceptions.from_code(error_code)
--> 635 raise error_class(parsed_response, operation_name)
636 else:
637 return parsed_response
InvalidRequestException: An error occurred (InvalidRequestException) when calling the StartTextTranslationJob operation: NO_READ_ACCESS_TO_S3: The provided data access role does not have proper access to the input/output S3 URI.
如果我遺漏任何東西,任何指針。 同樣為澄清起見,這是在提供該服務的愛爾蘭運行的。
我試圖重現這種情況並收到:
botocore.errorfactory.InvalidRequestException:調用 StartTextTranslationJob 操作時發生錯誤 (InvalidRequestException):OUTPUT_S3_URI_INVALID:提供的 output S3 URI 無效或不存在。
然后我將我的 output 更改為純粹指向存儲桶(沒有子目錄)並且它有效!
然后我將一個文件復制到一個子目錄(例如aws cp foo.txt s3://my-bucket/aws-translate/assets/output/
)並重新運行該程序並且它工作了!
底線:確保 output 目錄已經存在(通過將文件放在該路徑中,或使用 S3 管理控制台中的“創建文件夾”來創建 output 目錄)。
作為記錄,我的 IAM 角色具有AmazonS3FullAccess
策略和以下信任策略:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "translate.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.