I am using java to upload and download files from s3. My problem is that I can’t check in the code along with the secret and access key to public but the code has to checked in to a public environment. How can I manage my credentials separately and access only its references in my code?
the code I used is
String awsAccessKey = "YOUR_AWS_ACCESS_KEY";
String awsSecretKey = "YOUR_AWS_SECRET_KEY";
AWSCredentials awsCredentials =
new AWSCredentials(awsAccessKey, awsSecretKey);
I want the credentials manager to be platform independent.
You could implement an
AWSCredentialsProvider, which is an interface for supplying credentials to SDK clients. For example the
DefaultAWSCredentialsProviderChain is an implementation which looks in multiple places for credentials (the environment, a properties file, and EC2 instance profile).
You can check out the implementation of several credentials providers in the AWS SDK for Java Github repo.