Go语言 AWS Transcribe服务输出拒绝访问的文件,即使设置了权限

ykejflvf  于 2022-12-07  发布在  Go
关注(0)|答案(1)|浏览(141)

我正在运行start transcritpion作业后测试项目的AWS transcribe服务

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
}

文件正确输出指定名称的w.json,但内容显示错误

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

我是aws的新手,我不确定问题出在哪里
我是AWS的新手,我不确定问题出在哪里。我尝试了不同的IAM权限,但输出仍然相同。

t9aqgxwy

t9aqgxwy1#

您很可能需要S3存储桶的存储桶策略,以允许AWS Transcribe访问输入和输出存储桶,例如:

{
    "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/*"
        ]
    }
}

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

如所述here

相关问题