0

I am working on a project, where the user can upload an image which will be stored remotely.

I am building a Java web app through Elastic Beanstalk (EB), where the user's images will be stored in Simple Storage Service (S3).

The code required to do this works, however, it only does so remotely. When I run the application locally through WildFly, the user is capable of sending an image to S3, however, when I deploy my WAR to EB, the user cannot do it.

I have tried debugging and no exceptions are thrown, the code simply "stops" at one line. Said line:

s3Client = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(awsCredentials)).withRegion(Regions.US_EAST_1).build();

I have logged multiple messages and have found that the previous line is where the code "breaks". I've thought that perhaps it was because of my region, but I have double checked and it appears to be correct. Therefore, my question is:

How can I let my EB web application interact with my S3 bucket?

I do not understand how and why the code can work perfectly fine locally, but not work at all (without throwing exceptions) remotely. I am, therefore, starting to think that perhaps EB needs configuring to interact with S3 but I am unsure.

Any help would be greatly appreciated.

Thanks.

  • 1
    How are you providing credentials? Are you assigning an IAM role to the EC2 instances in your Beanstalk environment? Are the EC2 instances in a public or private subnet? – Mark B Mar 12 '17 at 21:01
  • For credentials my AccessKeyID and SecretAccessKey are hard coded and passed as a parameter to the AWSCredentials, which in turn is passed to AWSStaticCredentialsProvider. I believe I am assigning an IAM role to the EC2 instance. In my EC2 dashboard I have a security groups which accept inbound traffic from my IP address, but nothing in particular is assigned to S3. –  Mar 12 '17 at 21:30
  • My IAM user who's AccessKeyID and SecretAccessKey that I am using has the AmazonS3FullAccess permission attached. –  Mar 12 '17 at 21:46
  • You either use credentials or an IAM role, it sounds like you are using credentials. Security Group should be irrelevant here unless you added outbound rules. Is the EC2 instance in a private or public subnet of your VPC? – Mark B Mar 12 '17 at 22:12
  • I'm not sure. How do I check my EC2 being private or public? –  Mar 12 '17 at 22:26

0 Answers0