0

I referred to this https://github.com/awsdocs/amazon-s3-developer-guide/blob/master/doc_source/AuthUsingTempFederationTokenJava.md link but it shows a profile error that the profile file should not be null. another I referred this https://docs.aws.amazon.com/AmazonS3/latest/userguide/AuthUsingTempSessionToken.html even this doesn't work for me. any suggestion?

Sunny
  • 3
  • 1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 18 '21 at 06:50

1 Answers1

1

For both links you need to follow the instructions and not just copy/paste the code. The profile is null, because you most probably haven't created a ~/.aws/credentials file.

The process to test the code should be:

  • Create an IAM user, assign the appropriate permissions and create access keys
  • Add a profile to the ~/aws/credentials file with the keys of the user
  • Use the profile like new ProfileCredentialsProvider("app-1-development") in your code.

Please also refer here

kgiannakakis
  • 103,016
  • 27
  • 158
  • 194
  • I already created a user, got its accesskey and secretID, assigned the policy to it, everything was already done, even I tried to just upload file using accesskey and secretID and that was working, but I didn't understand the concept of the profile, I mean like how do I get profile and the location of ~/aws/credential or need to create that location where my credential file should be stored? – Sunny Oct 18 '21 at 06:45
  • AWSSecurityTokenService stsClient = AWSSecurityTokenServiceClientBuilder.standard().withRegion(clientRegion) .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKeyId, secretAccessKey))).build(); AssumeRoleRequest roleRequest = new AssumeRoleRequest().withRoleArn(roleARN).withRoleSessionName(roleSessionName); AssumeRoleResult roleResponse = stsClient.assumeRole(roleRequest); Credentials sessionCredentials = roleResponse.getCredentials(); current code im using – Sunny Oct 18 '21 at 06:48
  • error it shows User: arn:aws:iam:XXXXX:user/ is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam:XXXXX:role – Sunny Oct 18 '21 at 06:53
  • You are missing a trust relationship (https://stackoverflow.com/questions/41337079/how-enable-access-to-aws-sts-assumerole) – kgiannakakis Oct 18 '21 at 10:45