Working with AWS SDKs and IDE toolkits A Software Development Kit (SDK) or "devkit" is typically a set of software
159 ] Let's understand each folder and the internal files:
• Documentation: This folder contains all the content needed for reference. It has the syntax, package, structure, and description of each class/method. Using this documentation, we can understand the underlying class/method that we can use in our own library.
• Lib folder: This folder contains the .jar files that are necessary to start the development of AWS using your Java code. It contains other .jar files like the following:
° aws-java-sdk-<version>.jar: This contains all the classes required for AWS development, for example, class for AWS authentication and so on. Generally, people use dependency management tools, such as Gradle, Maven, or Ivy, to fetch the SDK jars. It is commonly used to execute all command-level operations from the command prompt. It can only be executed once they are configured in environment variables.
° aws-java-sdk-<version>-sources.jar: While creating code, if you want to attach source files for reference, you can only do that using this JAR.
There is one javadoc.jar file that stores the documentation for all AWS classes. Since it's optional, it's upon developers whether they need to keep them for reference.
• Samples: This folder contains the samples programs for quick understanding of code and its nature. In general, it's not easy to adapt new classes without understanding their basic flow. These codes will give you a hands-on exercise. The basic examples are as follows:
° Amazon-DynamoDB ° Amazon-EC2SpotInstances-GettingStarted ° Amazon-EC2SpotInstances-Advance ° Amazon-Kinesis ° Amazon-Kinesis-Application ° Amazon-s3 www.itbook.store/books/9781782173632
[ 160 ] ° AmazonS3TransferProgress ° AmazonSimpleEmailService ° AmazonSimpleQueueService ° AwsCloudFormation ° AwsConsoleApp ° AwsFlowFramework
• Third-party: This folder contains the third-party APIs that can be utilized in code structuring. Some third-party APIs are as follows:
° aspectj-1.6 ° commons-codec-1.3 ° commons-logging-1.1.1 ° freemarker-2.3.18 ° httpcomponents-client-4.2.3 ° jackson-annotations-2.1 ° jackson-core-2.1 ° jackson-databind-2.1 ° java-mail-1.4.3 ° joda-time-2.2 ° spring-3.0 ° stax-api-1.0.1 ° stax-ri-1.2.0
stax-api-1.0.1 and stax-ri-1.2.0 are not included in SDK v1.8.10.1
You can also add your own component, such as jQuery or others, for useful purposes and strong adaptability. This was all about the AWS SDK structure. While executing examples, you will see its usage and get an in-depth
understanding of flow and its components.
[ 161 ]
• The AWS Toolkit: The AWS Toolkit for Eclipse is an open source plugin for the Eclipse Java IDE that makes it easier for developers and code integrators to develop, debug, integrate, migrate, and deploy Java-based applications that use the AWS resources platform. There are some extraordinary functions/features that make the Amazon platform the best option for developers:
° AWS Explorer: This empowers you to correlate with numerous AWS services from the Eclipse IDE. The AWS Explorer provisions managed data services such as Amazon Simple Storage Service, Amazon SimpleDB, Amazon Simple Notification Service, and Amazon Simple Queue Service. AWS Explorer is further proposing to introduce Amazon Elastic Compute Cloud management and deployment functionality to the AWS Elastic Beanstalk via SDK or API. AWS Explorer provides various AWS accounts; you can undoubtedly transform the capitals presented in AWS Explorer from one account to alternative. AWS Explorer also empowers you with additional functionality such as the capability to design and accomplish key pairs and security groups.
The AWS Toolkit for Eclipse will install the newest version of the AWS SDK for the platform you have designated. From Eclipse, you can directly manage, modify, construct, and deploy any of the illustrations encompassed in the SDK packages. You can download and install it using the following steps:
1. Go to URL aws-amazon.com/sdk-for-java.
2. As shown in the following screenshot, click on AWS Toolkit for Eclipse:
[ 162 ]
3. Another way to configure this is to download Eclipse Juno/Luna from the link https://www.eclipse.org/downloads/.
4. Start Eclipse, go to Help, and then click on Install New Software.
5. In the Work with box, type http://aws.amazon.com/eclipse, and then press the Enter key.
6. In the list that appears, expand the AWS Toolkit for Eclipse option. 7. Select AWS Toolkit for Eclipse to download it.
8. Click on Next and the Eclipse wizard will take you through the other installation procedures by default.
To access AWS through the Eclipse Toolkit, you have to configure the Eclipse Toolkit with your access key ID and secret access key that should be available in your AWS account. In addition to allowing the Eclipse Toolkit to admit your account, your access keys are used to allow web services-based requirements to AWS. Allowing web services requests ensures that only approved programs can make such requests. Moreover, by associating access keys with each web services request, AWS will be able to track service usage for billing and monitoring.
The keys will have a combination of an access key ID and secret access key, which will be used to sign programmatic logical request that you will compose from application source code to AWS for accessing resources. If you don't have access keys, you can create the keys from the AWS Management Console. To do so, go to Security Credentials and select the Access Key ID option, as shown in the following screenshot:
[ 163 ]
A better way would be creating an IAM user or group with limited privileges (only those needed by an app developed) and use their access keys instead. This will also allow us to later mark the access keys as "inactive" or delete them when they are not needed any more. Using an account's root credentials for app development provides it with access to all AWS services and these credentials can't be easily revoked later. Keep the credentials confidential in order to guard your account, and never e-mail it. Do not share it with a third person from your organization, even if investigations come from AWS or from any other channel.
To add your access keys in the Eclipse Toolkit, follow the procedure given here: 1. Open the Eclipse AWS Toolkit Preferences dialog box and click on AWS
Toolkit located in the sidebar.
2. Type your access key ID in the Access Key ID box. 3. Type your secret access key in the Secret Access Key box. 4. Click on Apply or OK to store your access key information.
Here is an example of a configured AWS Toolkit Preferences screen with the default account:
The preceding dialog box enables you to add access information for more than one AWS accounts by selecting the designated profile. Multiple accounts enable developers and administrators to split resources that will be used for the development stage from resources that are used in the production stage.
[ 164 ]
To add another set of access keys, perform the following steps:
1. On the AWS Toolkit Preferences screen, go to the Profile Details, and click on Add Account button.
2. Add your account particulars to the Account Details section. 3. Pick a suitable name for Account Name and enter your access key
information in the Access Key ID and Secret Access Key boxes. 4. Click on Apply or OK.
5. You can repeat the preceding steps as practice for as many sets of AWS account intelligence that you require.
The Eclipse Toolkit can also achieve Amazon EC2 key pairs from an AWS account. Nevertheless, you will have to associate private keys to use in the Eclipse Toolkit manually. To observe Amazon EC2 key pairs in the Eclipse Toolkit, follow the next steps:
1. Open the Eclipse Preferences dialog box and click on AWS Toolkit in the sidebar to view the supplementary classifications of the Eclipse Toolkit surroundings and configure it.
2. Go to Key Pairs. Eclipse will display a list of available key pairs in that window. If a key pair has a red "X" sign next to it, you must create an association of a private key with the key pair to practice it with the present use case.
[ 165 ]
3. Right-click on the key pair and select Select Private Key File from the context menu. Go to the private key file and select it to subordinate it with your key pair, as shown here:
To employ the web application, you have to perform the following steps:
1. On the Eclipse toolbar, click on the AWS icon, and then select New AWS Java Web Project.
2. In the new AWS Java Web Project dialog box, in the Start from: option of the dialog box, set Travel Log as Sample Java Web Application and give a name myTravelLog in the Project name box.
3. Click on the Finish button. The toolkit will create the project and the project will be presented in Project Explorer.
If you aren't able to see Project Explorer in Eclipse, go to the Window
menu in Eclipse, click on Show View, and choose Project Explorer.
[ 166 ]