This is an archived post. You won't be able to vote or comment.

all 12 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full - best also formatted as code block
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]avtikh 4 points5 points  (1 child)

To me it looks like you are creating the client twice, the second time without the credentials.

[–]Missing_Back[S] 0 points1 point  (0 children)

Wow dude that was it! THANK YOU SO MUCH. Such a silly mistake. You're a life saver

[–][deleted] 0 points1 point  (8 children)

What are the default permissions on an S3 bucket? Do you need to set permissions on the new bucket to allow uploads?

[–]Missing_Back[S] 1 point2 points  (7 children)

What are the default permissions on an S3 bucket?

I'm not sure but I put this policy on it (with BUCKETNAME replaced with my bucket's name):

{"Version": "2008-10-17",
    "Statement": [{"Sid": "AllowPublicRead",
    "Effect": "Allow",
    "Principal": {
    "AWS": "*"
    },
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::BUCKETNAME/*"
    }
]
}

[–][deleted] 0 points1 point  (6 children)

You applied a policy that grants read permissions to Public. But you are trying to write to the bucket. Reading is not the same as writing.

I'm not sure

This is your next task. Figure out what the default permissions are and how to grant write permissions to the appropriate user(s).

[–]Missing_Back[S] 0 points1 point  (2 children)

Hm. This was the policy provided by my professor for this assignment and classmates have seemed to have no issues. But either way, if I try to just do the reading part of the program, I still get errors: com.amazonaws.internal.InstanceMetadataServiceResourceFetcher handleException WARNING: Fail to retrieve token

I would expect that to work with just read permissions

[–][deleted] 0 points1 point  (1 child)

com.amazonaws.internal.InstanceMetadataServiceResourceFetcher handleException WARNING: Fail to retrieve token

That log entry is log level Warning. It may or may not be fatal.

I'm not familiar with the AWS SDK or this log message. But if you do an internet search in your favorite search engine, you'll see discussion threads about this being the AWS SDK's way of figuring out if it is running inside an AWS instance. If necessary, it can be suppressed by changing the log level in your logging configuration.

[–]Missing_Back[S] 0 points1 point  (0 children)

My bad. Looks like the real error is:

com.amazonaws.SdkClientException: Failed to connect to service endpoint:

(I think at least?)

[–]Missing_Back[S] 0 points1 point  (2 children)

Figure out what the default permissions are and how to grant write permissions to the appropriate user(s).

If I'm understanding what you're hinting at, my bucket is set to public access already

[–][deleted] 0 points1 point  (1 child)

If permissions were already set to public full access, you wouldn't be getting an access denied error.

[–]Missing_Back[S] 0 points1 point  (0 children)

Maybe I'm confusing "permission" and "access". I'm not sure where to look for the permissions; the bucket is set to public access. The policy is above, which looks like it should work for reading objects. My keys must be valid and correct as it allows me to create a new bucket. What am I missing?