Translate is not authorized to assume role

1.7k views Asked by At

When I enter the example code from here 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

Then the following error is throw:

An error occurred (InvalidRequestException) when calling the StartTextTranslationJob operation: Translate is not authorized to assume role: arn:aws:iam::012345678901:role/service-role/AmazonTranslateInputOutputAccess. Please update the role's trust policy.

The role AmazonTranslateInputOutputAccess is already created but anyhow should be affect the thrown error.

2

There are 2 answers

0
Rene B. On

Could fix it by adding a trust policy of:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
        "Service": "translate.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}
0
Abhishek Singh On

Adding this will fix the issue.

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

If You want to auto detect the source language and translate the text, then you also have to add the comprehend action in your Iam role.

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