User guide
Step 1: Setting Up Your Credentials
To begin using this code sample, you need to populate your credentials in the
AwsCredentials.properties file. Specifically, you need to populate your secret key and access key.
Copy and paste your access key ID and secret access key into the AwsCredentials.properties file.
To get your access key ID and secret access key
Access keys consist of an access key ID and secret access key, which are used to sign programmatic
requests that you make to AWS. If you don't have access keys, you can create them by using the AWS
Management Console. We recommend that you use IAM access keys instead of AWS root account
access keys. IAM lets you securely control access to AWS services and resources in your AWS account.
Note
To create access keys, you must have permissions to perform the required IAM actions. For
more information, see Granting IAM User Permission to Manage Password Policy and Credentials
in Using IAM.
1. Open the IAM console.
2. From the navigation menu, click Users.
3. Select your IAM user name.
4. Click User Actions, and then click Manage Access Keys.
5. Click Create Access Key.
Your keys will look something like this:
• Access key ID example: AKIAIOSFODNN7EXAMPLE
• Secret access key example: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
6. Click Download Credentials, and store the keys in a secure location.
Your secret key will no longer be available through the AWS Management Console; you will have
the only copy. Keep it confidential in order to protect your account, and never email it. Do not share
it outside your organization, even if an inquiry appears to come from AWS or Amazon.com. No one
who legitimately represents Amazon will ever ask you for your secret key.
Related topics
• What Is IAM? in Using IAM
• AWS Security Credentials in AWS General Reference
Now that you have configured your settings, you can get started using the code in the example.
Step 2: Setting Up a Security Group
A security group acts as a firewall that controls the traffic allowed in and out of a group of instances. By
default, an instance is started without any security group, which means that all incoming IP traffic, on any
TCP port will be denied. So, before submitting our Spot Request, we will set up a security group that
allows the necessary network traffic. For the purposes of this tutorial, we will create a new security group
called "GettingStarted" that allows Secure Shell (SSH) traffic from the IP address where you are running
your application from.To set up a new security group, you need to include or run the following code
sample that sets up the security group programmatically.
Version v1.0.0
36
AWS SDK for Java Developer Guide
Tutorial: Amazon EC2 Spot Instances