admin管理员组

文章数量:1122846

I want to set the Environment variables-AWS_ACCESS_KEY_ID, AWS_SECRET_KEY or AWS_SECRET_ACCESS_KEY, and AWS_SESSION_TOKEN

BasicSessionCredentials awsCreds = new BasicSessionCredentials("access_key_id", "secret_key_id", "session_token");
AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
                        .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
                        .build();

but from the console I only have the AWS_ACCESS_KEY_ID, AWS_SECRET_KEY, not the token:

I want to set the Environment variables-AWS_ACCESS_KEY_ID, AWS_SECRET_KEY or AWS_SECRET_ACCESS_KEY, and AWS_SESSION_TOKEN

BasicSessionCredentials awsCreds = new BasicSessionCredentials("access_key_id", "secret_key_id", "session_token");
AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
                        .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
                        .build();

but from the console I only have the AWS_ACCESS_KEY_ID, AWS_SECRET_KEY, not the token:

Share Improve this question edited yesterday Nuñito Calzada asked yesterday Nuñito CalzadaNuñito Calzada 2,24253 gold badges197 silver badges326 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Two things:

  1. Use BasicAWSCredentials to pass just an accessKey and secretKey. The session one isn't needed for simple applications. It's used for short term / temporary credentials and if you're just starting out, keep it simple.
  2. You're using version 1 of the Java SDK if you're using BasicSessionCredentials. While Amazon still supports version 1 of the Java SDK they have already stopped general support and will drop all support at the end of 2025. The AWS Java SDK version 2 has been out for quite some time and is super stable - I'd strongly encourage you to use it instead.

本文标签: springcredentials to the AWS SDK 112780 for JavaStack Overflow