Creates an authenticated client which is allowed to use the selected service REST API. The following is the application class diagram:
📝 You need to set up your AWS user's security credentials to be able to use the service REST API.
You do this by creating a file named credentials in the ~/.aws/ on Mac (*C:\Users\USER_NAME.aws* on Windows) and saving the following lines in the file:
[default]
aws_access_key_id = your access key
aws_secret_access_key = your secret key
For more information, see Providing AWS Credentials in the AWS SDK for Java and Welcome to Identity and Access Management.
🚨 To avoid accidental leakage of your credentials, DO NOT keep the credentials file in your source directory.
📝 At his time the application only provides authentication for EC2 and S3. New service authentication will be added.
To access Amazon Web Services, you need an AWS account and AWS credentials. To increase the security of your AWS account, it is recommended to use an Identity Access Management (IAM) user to provide access credentials instead of using your root account credentials.
- In the AWS dashboard click on Services.
- In the Security, Identity & Compliance section, select IAM.
- In the left pane, select the Groups menu item.
- In the upper left click the Create New Group button.
- Enter the name of the group.
- Select the Permissions if any you want to apply to the entire group.
For instance AmazonEC2 FullAccess, We recommend you do not assign any permission, assign them on user's basis instead. - Click the Next Step button.
- Review the group info, then click the Create Group button.
- In the AWS dashboard click on Services.
- In the Security, Identity & Compliance section, select IAM.
- In the left pane, select the Users menu item.
- In the upper left, click thje Add user button.
- In the User name box enter the name of your choosing.
- In the Access type section, check mark the Programmatic access box.
This enable access key ID and secret access key for the AWS API, CLI, SDK, and other development tools. - Click the Next Permissions button.
- At this point, you can add the user to an existing group (or create a new group).
- Select the group for the user.
- Click the Next Review button.
- Click the Create user button.
- In the bottom right, click the Close button.
- Click on the name of the user you just created.
- Click the Add permissions button.
- Select the Attach existing policies button.
- Search for one or more policy types you want to attach.
- Check mark the box on the left of the policy names.
- Click the Next Review button.
- Click the Add permissions button.
- Click the Security credentials tab.
- Click the Create access key button.
- In the pop-up window, click the Donwload.csv file button.
- This downloads the accessKeys.csv file which contains the access key ID and secret access key to use in the credentials file.
- Click the Close button.
In your client application follow these steps:
- Instantiate the AuthenticateAwsServiceClient class.
- Obtain the authenticated client.
The following is an example:
// Instantiate the AuthenticateAwsServiceClient class.
AuthenticateAwsServiceClient authClient =
new AuthenticateAwsServiceClient();
// Get the authenticated client.
ec2Client = authClient.getAuthenticatedS3Client(currentRegion);
📝 When you build your client application, assure that you add this aws-client-auth program in your client application program path.