-1

Hi I have build an app in spring boot that uses amazon textract for getting table data from a pdf file. This app works correctly when it is installed on my localhost. Now i have created a new Elastic Beanstalk app on the AWS environment and uploaded my spring jar on there. When i call the url for the app i can verify that the app is there but when i call any of the endpoints that in turn call the textract service i get a permissions error.

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)

Can anyone give me advice as to how / where i can set this up?

Thanks

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Amir
  • 172
  • 14

1 Answers1

1

When you run a Spring Boot application on Elastic Beanstalk, you need to make sure you are setting your service client properly. If you do not, you encounter issues. For example, here is a way to create a service client for Amazon DynamoDB for the Java V2 client:

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

You can set up environment variables on Elastic Beanstalk so that the service client is successfully created. More information here:

Creating your first AWS Java web application

smac2020
  • 9,637
  • 4
  • 24
  • 38
  • Thank you, that's interesting. When i run my spring boot app from eclipse i pass a couple of env variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. Which are not available when i upload to EBS app. So should i be including those in the code similar to how you have suggested? – Amir Jan 11 '21 at 16:13
  • 1
    Exactly -- follow this article (replacing the Java code to use your specific service), You need to set the environment variables mentioned in this article. Once you do, you should have no issues. I have deployed many Spring BOOT APPS on Elastic Beanstalk and once variables are set, they work. – smac2020 Jan 11 '21 at 16:16
  • Thank you i will give it a try. – Amir Jan 11 '21 at 16:18
  • Ok i added this line Region region = Region.EU_WEST_2; TextractClient textractClient = TextractClient.builder().region(region) .credentialsProvider(EnvironmentVariableCredentialsProvider.create()).build(); and i know where the place is for adding env vars in EBS. But does that make it into a paid service? – Amir Jan 11 '21 at 16:54
  • 1
    Most of this should fall under Free tier. Check https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&all-free-tier.sort-order=asc – smac2020 Jan 11 '21 at 16:58
  • 1
    Thank you that was the issue. Now it's working correctly. – Amir Jan 12 '21 at 09:54