Amazon Textract、Elastic Beanstalk -assumed-role/aws-elasticbeanstalk-ec2-role/... 无权执行 textract:AnalyzeDocument

Amazon Textract, Elastic Beanstalk -assumed-role/aws-elasticbeanstalk-ec2-role/... is not authorized to perform textract:AnalyzeDocument

您好,我已经在 spring 启动中构建了一个应用程序,它使用 amazon textract 从 pdf 文件中获取 table 数据。当这个应用程序安装在我的本地主机上时,它可以正常工作。 现在,我已经在 AWS 环境中创建了一个新的 Elastic Beanstalk 应用程序,并将我的 spring jar 上传到那里。当我为应用程序调用 url 时,我可以验证该应用程序是否存在,但是当我调用任何端点,而这些端点又调用 textract 服务时,我收到权限错误。

User: arn:aws:sts::1234:assumed-role/aws-elasticbeanstalk-ec2-role/i-1234 is not authorized to perform textract:AnalyzeDocument (Service: Textract, Status Code: 400, Request ID: 123xyz, Extended Request ID: null)

任何人都可以就如何/在哪里设置它给我建议吗?

谢谢

当您 运行 在 Elastic Beanstalk 上启动 Spring 应用程序时,您需要确保正确设置服务客户端。如果不这样做,就会遇到问题。例如,下面是为 Java V2 客户端创建 Amazon DynamoDB 服务客户端的方法:

 DynamoDbClient ddb = DynamoDbClient.builder()
            .region(region)
            .credentialsProvider(EnvironmentVariableCredentialsProvider.create())
            .build(); 

您可以在Elastic Beanstalk上设置环境变量,以便成功创建服务客户端。更多信息在这里:

Creating your first AWS Java web application