go to  ForumEasy.com   
JavaPro  
 
 
   Home  |  MyForum  |  FAQ  |  Archive    You are not logged in. [Login] or [Register]  
Forum Home » Amazon AWS » API -- Connection to AWS
Email To Friend  |   Set Alert To This Topic Rewarding Points Availabe: 0 (What's this) New Topic  |   Post Reply
Author Topic: API -- Connection to AWS
AwsEC2
member
offline   
 
posts: 39
joined: 08/28/2012
from: CA
  posted on: 10/04/2019 01:23:22 AM    Edit  |   Quote  |   Report 
API -- Connection to AWS
When a user want to connect to a server like AWS, he/she needs USERNAME+PASSWORD to authenticate himself/herself to the server before getting any protected information. The same logic applies here when a API/robot is trying to connect to AWS -- a service account is needed for API calling. The service account consists of:
    access_key_id: JKT3AKUV3DI8VXCRMNQ2
secret_access_key: H2d6NHSPN7G8wuH7+hjRFhd+tMJhTu87DjJzmjgM


Here, access_key_id is like USERNAME which is public and secret_access_key is like PASSWORD which should be kept secret.

 Profile | Reply Points Earned: 0
AwsEC2
member
offline   
 
posts: 39
joined: 08/28/2012
from: CA
  posted on: 10/04/2019 01:26:08 AM    Edit  |   Quote  |   Report 
Way to set API's credentials

Way#1 Via explicitly input
Example
    BasicAWSCredentials awsCreds = new BasicAWSCredentials(
        "JKT3AKUV3DI8VXCRMNQ2",                    // "access_key_id", 
        "H2d6NHSPN7G8wuH7+hjRFhd+tMJhTu87DjJzmjgM" // "secret_acess_key"
    );	  
	    	  
    AmazonS3 s3Client = AmazonS3ClientBuilder.standard().
	  		  withRegion(Regions.US_EAST_1).
	  		  withCredentials(new AWSStaticCredentialsProvider(awsCreds)).
	  		  build();	    	  




Way#1 Via loading order
  • Environment Variables: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
  • Java System Properties: aws.accessKeyId and aws.secretKey
  • From file with environment variable: AWS_CREDENTIAL_PROFILES_FILE=path/to/file

    aws_access_key_id={YOUR_ACCESS_KEY_ID}
    aws_secret_access_key={YOUR_SECRET_ACCESS_KEY}
    


    Example
        System.setProperty("aws.accessKeyId", "JKT3AKUV3DI8VXCRMNQ2");
        System.setProperty("aws.secretKey", "H2d6NHSPN7G8wuH7+hjRFhd+tMJhTu87DjJzmjgM");
    	    	  
        AmazonS3 s3Client = AmazonS3ClientBuilder.standard().
    	  		  withRegion(Regions.US_EAST_1).
    	  		  build();	    	  
    


  •  Profile | Reply Points Earned: 0

     
    Powered by ForumEasy © 2003-2005, All Rights Reserved. | Privacy Policy | Terms of Use
     
    Get your own forum today. It's easy and free.