Search code examples
amazon-web-servicesgoamazon-s3amazon-transcribe

AWS Transcribe service outputs a file with access denied, even with permissions set


I am testing the AWS transcribe service for a project, after runing the start transcritpion job

var TrsSession *transcribeservice.TranscribeService

func TranscribeTest() (trsOutput *transcribeservice.StartTranscriptionJobOutput, err error) {
    trsOutput, err = TrsSession.StartTranscriptionJob(&transcribeservice.StartTranscriptionJobInput{
        TranscriptionJobName: aws.String("gettysburg_test"),
        IdentifyLanguage:     aws.Bool(true),
        MediaFormat:          aws.String("wav"),
        OutputBucketName:     aws.String(os.Getenv("AWS_BUCKET_NAME")),
        Media: &transcribeservice.Media{
            MediaFileUri: aws.String("s3://" + os.Getenv("AWS_BUCKET_NAME") + "/gettysburg.wav"),
        },
    })

    if err != nil {
        fmt.Println(err)
        return trsOutput, err
    }

    return trsOutput, nil
}

the file outputs properly wwith the specified name .json but the content shows an error

<Error>
  <Code>AccessDenied</Code>
  <Message>Access Denied</Message>
  <RequestId>JDP5*****5QQJ</RequestId>
  <HostId>wnd5k6x********************TDwqIpe53S1w=</HostId>
</Error>

I am new to aws I am not sure where the problem is

I am new to aws I am not sure where the problem is. I tried different IAM permission but still the same output.


Solution

  • You most likely need bucket policies for your S3 buckets to allow AWS Transcribe to access both the input and output buckets, for example:

    {
        "Version": "2012-10-17",
        "Statement": {
            "Effect": "Allow",
            "Principal": {
              "Service": [
                "transcribe.amazonaws.com"
              ]
            },
            "Action": [
                "s3:GetObject",
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::DOC-EXAMPLE-INPUT-BUCKET",
                "arn:aws:s3:::DOC-EXAMPLE-INPUT-BUCKET/*"
            ]
        }
    }
    

    and

    {
        "Version": "2012-10-17",
        "Statement": {
            "Effect": "Allow",
            "Principal": {
              "Service": [
                "transcribe.amazonaws.com"
              ]
            },
            "Action": [
                "s3:PutObject"
            ],
            "Resource": [
                "arn:aws:s3:::DOC-EXAMPLE-OUTPUT-BUCKET/*"
            ]
        }
    }
    

    as described here