Working with AWS SDKs and IDE toolkits A Software Development Kit (SDK) or "devkit" is typically a set of software
166 ]Now you are ready to start.
The AWS Java Web Project dialog box will allow you to choose the region in which your web application will be deployed to and run from. Here, I am going to select US East (Virginia), as it is the cheapest one in my case.
[ 167 ]
After selecting the proper Region, you have to proceed with the selection of container in the following manner:
1. From Project Explorer, navigate to myTravelLog | Run As | Run on Server. 2. In the Run on Server dialog box, select Manually define a new server and
click on AWS Elastic Beanstalk for Tomcat 7 from the catalog of specified server choices.
3. Enter an appropriate name, such as TravelLogServer, into the server's hostname box or provide a specific name of your choice.
4. Finally, choose Always use this server when running this project and select Next.
[ 168 ]
5. In the Run On Server box, supply an application name, such as
myTravelLogApp, and an environment name, such as myTravelLogEnv. Then, click on Next. This is shown in the following screenshot:
[ 169 ]
6. Go to Run On Server | Advanced configuration. The Advanced
configuration dialog box allows you to state further parameters for your
web application reference, such as IAM role, CNAME, Announcement email address, and so on.
7. Before deploying your application to AWS Beanstalk container, the toolkit will display a dialog box where you can fix a Version Label where you can specify the version number. The AWS Toolkit will produce a distinctive version label which is time stamped but still editable.
8. Click on OK.
9. While your application is deploying, the AWS Toolkit will display a progress status, as shown in the following screenshot:
[ 170 ]
10. When the deployment is complete, you will be able to see the following screen. This is the user interface for the Travel Log application that will be running on your Amazon EC2 instance.
So, the preceding example was about Elastic Beanstalk deployment using AWS SDK Toolkit. Let's see one more example with the NoSQL database called DynamoDB from AWS to get more hands-on experience.
In Eclipse, you can see a new icon . This is the AWS Toolkit for Eclipse icon. The default Eclipse perspective will be Java; to open the perspective to work with DynamoDB, go to Window and select the Open Perspective option. It must show the first two perspectives, as shown here:
[ 171 ]
11. Double-click on AWS Management to start working. While working in the AWS Management Console, we must log in with our AWS username and password. But for the Eclipse plugin, we need to specify a few more attributes for authentication. We can specify our account details by clicking on the AWS Eclipse Toolkit icon and selecting the Preferences option.
12. The pop-up window that appears will ask for the following details, which we can fetch from security page in the AWS Management Console.
13. Once the configuration is successful, all the AWS components will be loaded. You can right-click on corresponding service and select refresh to get the latest data. The icon in the top-right (with US flag) is the region that you have currently selected. If the DynamoDB table is created in the US East (Virginia) region using AWS management console, and if you have selected the US West (Oregon) region here in Eclipse, then you will not be able to see that table in your perspective.
[ 172 ]
14. You can change the region with a single click on the drop-down with the flag on top-right.
15. Once the desired region is selected, right-click on Amazon DynamoDB and choose Create Table option.
[ 173 ]
16. The Create Table option will open the following window and ask for the mandatory parameters to be passed while creating a table.
17. Since the index has to be created along with the table, you need to specify (if any) the secondary indexes here itself.
18. After that, the table will be created and it becomes active.
[ 174 ]
19. Double clicking on the table name will open the following tab. There will be five icons (just after the table name) in the tab. We will look at the functionalities of each icon later. Now, you need to focus only on the last icon, which is used to add attributes to the table.
20. Clicking on the "Add attribute" column icon will open the following window that asks us to enter the name of the attribute to be created (it will not ask for the type):
21. After adding the necessary attributes, click on the grid to insert a value. By default, all attributes will be treated as string type; to change its number type, just click on the button a (as shown in the Publisher column) in the following screenshot:
22. Clicking on the button a will open a drop-down from which we can choose whether we want the field to be a string or number. You might ask, "How can I insert a set data type?" The answer lies in the next screenshot:
[ 175 ]
23. To change an attribute type from normal type to a set, just click on the icon with ellipses (…). It will open an Edit values window that asks whether we need to make this attribute a string or a string set. Click on <new value> to add new value to this set.
24. After inserting all the necessary attributes for an item, click on the grid below the item. The item with attribute values entered will appear in red color, which means the item is not saved into the table.
25. Let's discuss the DynamoDB utility icons. The first icon is used to run a scan on the DynamoDB table, the second icon is used to pause the scan, the third saves the items into the table, and the fourth icon is used to export table data into a CSV file. The last icon is used to add an attribute to the DynamoDB table.
[ 176 ]
26. Now, let's see how to scan a table using the Eclipse plugin. Clicking on the Add scan condition icon (in the previous screenshot) will open the following options. In the textbox next to the Attribute check box, enter the attribute name to be queried and select the comparison operation to be performed. Then, enter the selection criteria and click on the scan icon (first one). It will retrieve the result as follows: