1

当我从这里输入示例代码https://docs.aws.amazon.com/de_de/translate/latest/dg/async.html

$ aws translate start-text-translation-job --job-name batch-test \
--source-language-code en \
--target-language-codes fr \
--input-data-config S3Uri=s3://input-bucket-name/folder,ContentType=text/plain \
--output-data-config S3Uri=s3://output-bucket-name/ \
--data-access-role-arn arn:aws:iam::012345678901:role/service-role/AmazonTranslateInputOutputAccess

然后抛出以下错误:

调用 StartTextTranslationJob 操作时发生错误 (InvalidRequestException):Translate 无权担任角色:arn:aws:iam::012345678901:role/service-role/AmazonTranslateInputOutputAccess。请更新角色的信任策略。

角色 AmazonTranslateInputOutputAccess 已经创建,但无论如何应该会影响抛出的错误。

4

2 回答 2

2

可以通过添加以下信任策略来修复它:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
        "Service": "translate.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}
于 2020-11-27T08:06:32.943 回答
1

添加这将解决问题。

{
"Version": "2012-10-17",
"Statement": [
    {
        "Sid": "AllowTranslation",
        "Effect": "Allow",
        "Resource": "*",
        "Action": "translate:*"
    }
  ]
}

如果您想自动检测源语言并翻译文本,那么您还必须在您的 Iam 角色中添加理解操作。

{
"Version": "2012-10-17",
"Statement": [
    {
        "Sid": "AllowTranslation",
        "Effect": "Allow",
        "Resource": "*",
        "Action": [ "translate:*", "comprehend:*" ]
    }
  ]
}
于 2021-12-18T05:41:53.753 回答