AWS SDK for Java Developer Guide Version v1.0.
AWS SDK for Java Developer Guide AWS SDK for Java: Developer Guide Copyright © 2015 Amazon Web Services, Inc. and/or its affiliates. All rights reserved. The following are trademarks of Amazon Web Services, Inc.
AWS SDK for Java Developer Guide Table of Contents What is the AWS SDK for Java? ....................................................................................................... 1 About the AWS SDK for Java ................................................................................................... 1 Browse the Source at GitHub .......................................................................................... 1 Developing AWS Applications for Android ..................................
AWS SDK for Java Developer Guide Listing Amazon SWF Domains ....................................................................................... Additional Resources ................................................................................................................... Home Page for the AWS SDK for Java ..................................................................................... SDK Reference Documentation .............................................................................
AWS SDK for Java Developer Guide About the AWS SDK for Java What is the AWS SDK for Java? The AWS SDK for Java provides a Java API for AWS infrastructure services. Using the SDK for Java, you can build applications that work with Amazon Simple Storage Service (Amazon S3), Amazon Elastic Compute Cloud (Amazon EC2), Amazon SimpleDB, and more. New AWS services are occasionally added to the AWS SDK for Java.
AWS SDK for Java Developer Guide Developing AWS Applications for Android Developing AWS Applications for Android If you are an Android developer, Amazon Web Services publishes a separate SDK specifically for Android development. For more information, go to the documentation for the AWS SDK for Android.
AWS SDK for Java Developer Guide About Amazon Web Services About Amazon Web Services Amazon Web Services (AWS) is a collection of digital infrastructure services that developers can leverage when developing their applications. The services include computing, storage, database, and application synchronization (messaging and queuing). AWS uses a pay-as-you-go service model. You are charged only for the services that you—or your applications—use.
AWS SDK for Java Developer Guide Sign Up for Amazon Web Services and Get AWS Credentials Getting Started This section provides information about how to install, set up, and use the SDK for Java. If you have never used the SDK for Java before, you should start here. Topics • Sign Up for Amazon Web Services and Get AWS Credentials (p. 4) • Install a Java Development Environment (p. 5) • Install the AWS SDK for Java (p. 5) • Using the SDK for Java with Apache Maven (p.
AWS SDK for Java Developer Guide Install a Java Development Environment To provide access credentials for an IAM user 1. Sign in to the AWS Management Console and open the IAM console at https:// console.aws.amazon.com/iam/. 2. 3. 4. Click Users to view your IAM users. If you don't have any IAM users set up, click Create User to create one. Click the IAM user for whom you want to provide access credentials. 5. 6. Under Security Credentials, click Manage Access Keys.
AWS SDK for Java Developer Guide Using the SDK for Java with Apache Maven To download and install the SDK for Java 1. Download the SDK for Java from the SDK web page at http://aws.amazon.com/sdkforjava. 2. After downloading the SDK, extract the contents into a directory. Using the SDK for Java with Apache Maven You can use Apache Maven to build SDK for Java projects and to build the SDK for Java itself. Configuring the SDK as a Maven dependency Beginning with version 1.9.
AWS SDK for Java Developer Guide Set Up your AWS Credentials for Use with the SDK for Java Set Up your AWS Credentials for Use with the SDK for Java To connect to any of the supported services with the SDK for Java, you must provide your AWS credentials. The AWS SDKs and CLIs use provider chains to look for AWS credentials in a number of different places, including system or user environment variables and local AWS configuration files.
AWS SDK for Java Developer Guide Explore the SDK for Java Code Samples Explore the SDK for Java Code Samples The SDK for Java is packaged with a number of code samples, which you can browse on your machine or view on GitHub. For more information about the samples that are provided, see SDK for Java Code Samples (p. 67). Where to Go from Here To learn more about the SDK for Java, you should start with AWS SDK for Java Basics (p.
AWS SDK for Java Developer Guide Providing Credentials AWS SDK for Java Basics This section provides important general information about programming with the AWS SDK for Java. Information in this section applies to all services that you might be using with the SDK for Java. For information that is specific to a particular service (EC2, SWF, etc.), see the Using AWS Services (p. 23) section. Topics • Providing AWS Credentials in the AWS SDK for Java (p. 9) • AWS Region Selection (p.
AWS SDK for Java Developer Guide Using the Default Credential Provider Chain Topics • Using the Default Credential Provider Chain (p. 10) • Specifying a Credential Provider or Provider Chain (p. 12) • Explicitly Specifying Credentials (p. 12) • See Also (p.
AWS SDK for Java Developer Guide Using the Default Credential Provider Chain To override the default credentials file location • Set the AWS_CREDENTIAL_FILE environment variable to the location of your AWS credentials file.
AWS SDK for Java Developer Guide Specifying a Credential Provider or Provider Chain Specifying a Credential Provider or Provider Chain If you want to specify a different credential provider than the default credential provider chain, you can specify it in the client constructor. To specify a specific credentials provider • Provide an instance of a credentials provider or provider chain to a service client constructor that takes an AWSCredentialsProvider interface as input.
AWS SDK for Java Developer Guide See Also See Also • Sign Up for Amazon Web Services and Get AWS Credentials (p. 4) • Set Up your AWS Credentials for Use with the SDK for Java (p. 7) • Using IAM Roles for EC2 Instances (p. 30) AWS Region Selection Regions enable you to access AWS services that reside physically in a specific geographic area. This can be useful both for redundancy and to keep your data and applications running close to where you and your users will access them.
AWS SDK for Java Developer Guide Choosing a Specific Endpoint AmazonEC2 ec2 = new AmazonEC2(myCredentials); ec2.setRegion(Region.getRegion(Regions.US_WEST_2)); Important AmazonWebServiceClient.setRegion is not thread-safe, so you should be careful when changing the region for an existing client. To avoid potential thread synchronization issues, create a new client object for each region that you are using.
AWS SDK for Java Developer Guide HTTP Transport Configuration If you're connecting to the Internet through a proxy server, you'll need to configure your proxy server settings (proxy host, port and username/password) through the ClientConfiguration object. HTTP Transport Configuration You can configure several HTTP transport options by using the ClientConfiguration object. New options are occasionally added; to see the full list of options that can be retrieved or set, see the SDK for Java reference.
AWS SDK for Java Developer Guide TCP Socket Buffer Size Hints TCP Socket Buffer Size Hints Advanced users who want to tune low-level TCP parameters can additionally set TCP buffer size hints through the ClientConfiguration object. The majority of users will never need to tweak these values, but they are provided for advanced users. Optimal TCP buffer sizes for an application are highly dependent on network and OS configuration and capabilities.
AWS SDK for Java Developer Guide Exception Handling java.security.Security.setProperty("networkaddress.cache.ttl" , "60"); Note that the JVM is a shared resource; multiple Java applications could be using the same JVM. The TTL value affects all Java applications that use the JVM. Exception Handling Understanding how and when the AWS SDK for Java throws exceptions is important in order to build high-quality applications using the SDK.
AWS SDK for Java Developer Guide Logging AmazonClientException This exception indicates that a problem occurred inside the Java client code, either while trying to send a request to AWS or while trying to parse a response from AWS. AmazonClientException exceptions are more severe than AmazonServiceException exceptions and indicate a major problem that is preventing the client from being able to make service calls to AWS services.
AWS SDK for Java Developer Guide Service-Specific Errors and Warnings If you are using the Eclipse IDE, you can set the classpath by navigating to: Project | Properties | Java Build Path Service-Specific Errors and Warnings We recommend that you always leave the "com.
AWS SDK for Java Developer Guide Verbose Wire Logging POST https://rds.amazonaws.com / Parameters: (MaxRecords: 20, Action: Descri beEngineDefaultParameters, SignatureMethod: HmacSHA256, AWSAccessKeyId: ACCESS KEYID, Version: 2009-10-16, SignatureVersion: 2, Engine: mysql5.1, Timestamp: 2009-12-17T17:53:04.267Z, Signature: 4ydexGGkC77PovHhbfzAMA1H0nD nqIQxG9q+Yq3uw5s=, ) 2009-12-17 09:53:04,464 [main] DEBUG com.amazonaws.
AWS SDK for Java Developer Guide Access Control Policies A is the principal The AWS account that is making a request to access or modify one of your AWS resources. B is the action The way in which your AWS resource is being accessed or modified, such as sending a message to an Amazon SQS queue, or storing an object in an Amazon S3 bucket. C is the resource Your AWS entity that the principal wants to access, such as an Amazon SQS queue, or an object stored in Amazon S3.
AWS SDK for Java Developer Guide Access Control Policies AmazonSQS sqs = new AmazonSQSClient(myAwsCredentials); sqs.setQueueAttributes(new SetQueueAttributesRequest(myQueueUrl, queueAttrib utes)); Amazon SNS Example Some services offer additional conditions that can be used in policies. Amazon SNS provides conditions for allowing or denying subscriptions to SNS topics based on the protocol (e.g., email, HTTP, HTTPS, SQS) and endpoint (e.g.
AWS SDK for Java Developer Guide DynamoDB Using Amazon Web Services with the AWS SDK for Java This section provides information about how to program various Amazon Web Services using the SDK for Java. Topics • Programming DynamoDB with the AWS SDK for Java (p. 23) • Programming Amazon EC2 with the AWS SDK for Java (p. 26) • Getting Temporary AWS Credentials with SWS STS (p. 61) • Programming Amazon SWF with the AWS SDK for Java (p.
AWS SDK for Java Developer Guide Manage Tomcat Session State with DynamoDB Downloading the Session Manager You can download the session manager from the aws/aws-dynamodb-session-tomcat project on GitHub. That project also hosts the session manager source code if you want to contribute to the project by sending us pull requests or opening issues.
AWS SDK for Java Developer Guide Manage Tomcat Session State with DynamoDB • A config file that copies the jar into Tomcat's lib directory and applies the overridden context.xml file. You can find in more information on customizing the Elastic Beanstalk environments in the developer guide for that service.
AWS SDK for Java Developer Guide Amazon EC2 Troubleshooting If you encounter issues with the session manager, the first place to look is in catalina.out. If you have access to the Tomcat installation, you can go directly to this log file and look for any error messages from the session manager. If you're using Elastic Beanstalk, you can view the environment logs with the AWS Management Console or the AWS Toolkit for Eclipse. Limitations The session manager does not support session locking.
AWS SDK for Java Developer Guide Tutorial: Starting an EC2 Instance AWSCredentials credentials = new PropertiesCredentials( AwsConsoleApp.class.getResourceAsStream("AwsCredentials.proper ties")); 2. Use the AWSCredentials object to create a new AmazonEC2Client instance, as follows: amazonEC2Client = new AmazonEC2Client(credentials); 3. By default, the service endpoint is ec2.us-east-1.amazonaws.com.To specify a different endpoint, use the setEndpoint method. For example: amazonEC2Client.
AWS SDK for Java Developer Guide Tutorial: Starting an EC2 Instance If you attempt to create a security group with the same name as an existing security group, createSecurityGroup throws an exception. By default, a new security group does not allow any inbound traffic to your Amazon EC2 instance. To allow inbound traffic, you must explicitly authorize security group ingress. You can authorize ingress for individual IP addresses, for a range of IP addresses, for a specific protocol, and for TCP/UDP ports.
AWS SDK for Java Developer Guide Tutorial: Starting an EC2 Instance Create a Key Pair You must specify a key pair when you launch an EC2 instance and then specify the private key of the key pair when you connect to the instance. You can create a key pair or use an existing key pair that you've used when launching other instances. For more information, see Amazon EC2 Key Pairs in the Amazon EC2 User Guide for Linux Instances. To create a key pair and save the private key 1.
AWS SDK for Java Developer Guide Using IAM Roles for EC2 Instances .withMaxCount(1) .withKeyName("my-key-pair") .withSecurityGroups("my-security-group"); withImageId The ID of the AMI. For a list of public AMIs provided by Amazon, see Amazon Machine Images. withInstanceType An instance type that is compatible with the specified AMI. For more information, see Instance Types in the Amazon EC2 User Guide for Linux Instances. withMinCount The minimum number of EC2 instances to launch.
AWS SDK for Java Developer Guide Using IAM Roles for EC2 Instances 1. In system environment variables: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. 2. In the Java system properties: aws.accessKeyId and aws.secretKey. 3. In the default credentials file (the location of this file varies by platform). 4. In the instance profile credentials, which exist within the instance metadata associated with the IAM role for the EC2 instance.
AWS SDK for Java Developer Guide Using IAM Roles for EC2 Instances 5. 6. On the Set Permissions page, under Select Policy Template, select Amazon S3 Read Only Access. Click Next Step. On the Review page, click Create Role. Launch an EC2 Instance and Specify Your IAM Role You can launch an EC2 instance with an IAM role using the Amazon EC2 console or the SDK for Java.
AWS SDK for Java Developer Guide Using IAM Roles for EC2 Instances } catch(AmazonClientException ace) { System.out.println( "AmazonClientException" ); } } private static void displayTextInputStream(InputStream input) throws IOExcep tion { // Read one text line at a time and display. BufferedReader reader = new BufferedReader(new InputStreamReader(input)); while(true) { String line = reader.readLine(); if(line == null) break; System.out.println( " " + line ); } System.out.
AWS SDK for Java Developer Guide Using IAM Roles for EC2 Instances run: [java] Downloading an object [java] AmazonServiceException BUILD SUCCESSFUL Transfer the Compiled Program to Your EC2 Instance Transfer the program to your EC2 instance using secure copy (scp), along with the SDK for Java libraries. The sequence of commands looks something like the following. Depending on the Linux distribution that you used, the user name might be "ec2-user", "root", or "ubuntu".
AWS SDK for Java Developer Guide Tutorial: Amazon EC2 Spot Instances Tutorial: Amazon EC2 Spot Instances Overview Spot Instances allow you to bid on unused Amazon Elastic Compute Cloud (Amazon EC2) capacity and run the acquired instances for as long as your bid exceeds the current Spot Price. Amazon EC2 changes the Spot Price periodically based on supply and demand, and customers whose bids meet or exceed it gain access to the available Spot Instances.
AWS SDK for Java Developer Guide Tutorial: Amazon EC2 Spot Instances 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.
AWS SDK for Java Developer Guide Tutorial: Amazon EC2 Spot Instances After we create an AmazonEC2 client object, we create a CreateSecurityGroupRequest object with the name, "GettingStarted" and a description for the security group. Then we call the ec2.createSecurityGroup API to create the group.
AWS SDK for Java Developer Guide Tutorial: Amazon EC2 Spot Instances ipPermission.setFromPort(new Integer(22)); ipPermission.setToPort(new Integer(22)); ipPermission.setIpRanges(ipRanges); ipPermissions.add(ipPermission); 50 try { // Authorize the ports to the used. AuthorizeSecurityGroupIngressRequest ingressRequest = new AuthorizeSecurityGroupIngressRequest("GettingStartedGroup",ip Permissions); 55 ec2.
AWS SDK for Java Developer Guide Tutorial: Amazon EC2 Spot Instances There are many ways to approach bidding for Spot instances; to get a broad overview of the various approaches you should view the Bidding for Spot Instances video. However, to get started, we'll describe three common strategies: bid to ensure cost is less than on-demand pricing; bid based on the value of the resulting computation; bid so as to acquire computing capacity as quickly as possible.
AWS SDK for Java Developer Guide Tutorial: Amazon EC2 Spot Instances RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); // Request 1 x t1.micro instance with a bid price of $0.03. requestRequest.setSpotPrice("0.03"); 20 requestRequest.setInstanceCount(Integer.valueOf(1)); // Setup the specifications of the launch. This includes the // instance type (e.g. t1.micro) and the latest Amazon Linux // AMI id available.
AWS SDK for Java Developer Guide Tutorial: Amazon EC2 Spot Instances 10 // active state. for (SpotInstanceRequest requestResponse : requestResponses) { System.out.println("Created Spot Request: "+requestResponse.getSpotIn stanceRequestId()); spotInstanceRequestIds.add(requestResponse.getSpotInstanceRequestId()); } To monitor your request ID, call the describeSpotInstanceRequests method to determine the state of the request. Then loop until the request is not in the "open" state.
AWS SDK for Java Developer Guide Tutorial: Amazon EC2 Spot Instances } catch (Exception e) { // Do nothing because it woke up early. } 45 } while (anyOpen); After running this code, your Spot Instance Request will have completed or will have failed with an error that will be output to the screen. In either case, we can proceed to the next step to clean up any active requests and terminate any running instances.
AWS SDK for Java Developer Guide Tutorial: Amazon EC2 Spot Instances try { // Retrieve all of the requests we want to monitor. 20 DescribeSpotInstanceRequestsResult describeResult = ec2.describeS potInstanceRequests(describeRequest); List describeResponses = describeResult.get SpotInstanceRequests(); 25 30 35 40 // Look through each request and determine if they are all // in the active state.
AWS SDK for Java Developer Guide Tutorial: Advanced Amazon EC2 Spot Request Management Bringing It All Together To bring this all together, we provide a more object-oriented approach that combines the preceding steps we showed: initializing the EC2 Client, submitting the Spot Request, determining when the Spot Requests are no longer in the open state, and cleaning up any lingering Spot request and associated instances. We create a class called Requests that performs these actions.
AWS SDK for Java Developer Guide Tutorial: Advanced Amazon EC2 Spot Request Management 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 secretKey and accessKey. Copy and paste your access key ID and secret access key into the AwsCredentials.properties file.
AWS SDK for Java Developer Guide Tutorial: Advanced Amazon EC2 Spot Request Management After we create an AmazonEC2 client object, we create a CreateSecurityGroupRequest object with the name, "GettingStarted" and a description for the security group. Then we call the ec2.createSecurityGroup API to create the group.
AWS SDK for Java Developer Guide Tutorial: Advanced Amazon EC2 Spot Request Management ArrayList ipPermissions = new ArrayList (); 45 IpPermission ipPermission = new IpPermission(); ipPermission.setIpProtocol("tcp"); ipPermission.setFromPort(new Integer(22)); ipPermission.setToPort(new Integer(22)); ipPermission.setIpRanges(ipRanges); 50 ipPermissions.add(ipPermission); try { // Authorize the ports to the used.
AWS SDK for Java Developer Guide Tutorial: Advanced Amazon EC2 Spot Request Management // Initializes a Spot Instance Request RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); // Request 1 x t1.micro instance with a bid price of $0.03. 20 requestRequest.setSpotPrice("0.03"); requestRequest.setInstanceCount(Integer.valueOf(1)); // Set up the specifications of the launch. This includes the // instance type (e.g. t1.micro) and the latest Amazon Linux 25 // AMI id available.
AWS SDK for Java Developer Guide Tutorial: Advanced Amazon EC2 Spot Request Management // Initializes a Spot Instance Request RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); 20 // Request 1 x t1.micro instance with a bid price of $0.03. requestRequest.setSpotPrice("0.03"); requestRequest.setInstanceCount(Integer.valueOf(1)); // Set the type of the bid to persistent. 25 requestRequest.setType("persistent"); // Set up the specifications of the launch.
AWS SDK for Java Developer Guide Tutorial: Advanced Amazon EC2 Spot Request Management // Initializes a Spot Instance Request RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); // Request 1 x t1.micro instance with a bid price of $0.03. 20 requestRequest.setSpotPrice("0.03"); requestRequest.setInstanceCount(Integer.valueOf(1)); // Set the valid start time to be two minutes from now. Calendar cal = Calendar.getInstance(); 25 cal.add(Calendar.MINUTE, 2); requestRequest.
AWS SDK for Java Developer Guide Tutorial: Advanced Amazon EC2 Spot Request Management GettingStartedApp.class.getResourceAsStream("AwsCredentials.proper ties")); } catch (IOException e1) { System.out.println("Credentials were not properly entered into AwsCre dentials.properties."); System.out.println(e1.getMessage()); 10 System.exit(-1); } // Create the AmazonEC2Client object so we can call various APIs.
AWS SDK for Java Developer Guide Tutorial: Advanced Amazon EC2 Spot Request Management } catch (IOException e1) { System.out.println("Credentials were not properly entered into AwsCre dentials.properties."); System.out.println(e1.getMessage()); 10 System.exit(-1); } // Create the AmazonEC2Client object so we can call various APIs.
AWS SDK for Java Developer Guide Tutorial: Advanced Amazon EC2 Spot Request Management } // Create the AmazonEC2Client object so we can call various APIs. AmazonEC2 ec2 = new AmazonEC2Client(credentials); 15 // Initializes a Spot Instance Request RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); // Request 1 x t1.micro instance with a bid price of $0.03. 20 requestRequest.setSpotPrice("0.03"); requestRequest.setInstanceCount(Integer.
AWS SDK for Java Developer Guide Tutorial: Advanced Amazon EC2 Spot Request Management 10 System.exit(-1); } // Create the AmazonEC2Client object so we can call various APIs. AmazonEC2 ec2 = new AmazonEC2Client(credentials); 15 // Initializes a Spot Instance Request RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); // Request 1 x t1.micro instance with a bid price of $0.03. 20 requestRequest.setSpotPrice("0.03"); requestRequest.setInstanceCount(Integer.
AWS SDK for Java Developer Guide Tutorial: Advanced Amazon EC2 Spot Request Management interruption or termination. We've inserted new code in the following example that shows how to enable this scenario. In the added code, we create a BlockDeviceMapping object and set its associated Elastic Block Storage (EBS) to an EBS object that we've configured to not be deleted if the Spot Instance is terminated.
AWS SDK for Java Developer Guide Tutorial: Advanced Amazon EC2 Spot Request Management blockList.add(blockDeviceMapping); // Set the block device mapping configuration in the launch specifications. 50 launchSpecification.setBlockDeviceMappings(blockList); // Add the launch specification. requestRequest.setLaunchSpecification(launchSpecification); 55 // Call the RequestSpotInstance API. RequestSpotInstancesResult requestResult = ec2.
AWS SDK for Java Developer Guide Tutorial: Advanced Amazon EC2 Spot Request Management import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.PropertiesCredentials; 25 import com.amazonaws.codesamples.getting_started.GettingStartedApp; import com.amazonaws.services.ec2.AmazonEC2; import com.amazonaws.services.ec2.AmazonEC2Client; import com.amazonaws.services.ec2.model.CancelSpotInstanceRequestsRequest; import com.amazonaws.services.ec2.model.CreateTagsRequest; 30 import com.amazonaws.services.
AWS SDK for Java Developer Guide Tutorial: Advanced Amazon EC2 Spot Request Management System.out.println(e1.getMessage()); System.exit(-1); } 80 // Create the AmazonEC2Client object so we can // call various APIs. AmazonEC2 ec2 = new AmazonEC2Client(credentials); // Initializes a Spot Instance Request 85 RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); // Request 1 x t1.micro instance with a bid price of $0.03. requestRequest.setSpotPrice("0.03"); requestRequest.
AWS SDK for Java Developer Guide Tutorial: Advanced Amazon EC2 Spot Request Management 130 135 140 145 // Create the list of tags we want to create ArrayList requestTags = new ArrayList(); requestTags.add(new Tag("keyname1","value1")); // Create a tag request for the requests. CreateTagsRequest createTagsRequest_requests = new CreateTagsRequest(); createTagsRequest_requests.setResources(spotInstanceRequestIds); createTagsRequest_requests.
AWS SDK for Java Developer Guide Tutorial: Advanced Amazon EC2 Spot Request Management 185 190 195 200 205 210 if (describeResponse.getState().equals("open")) { anyOpen = true; break; } // Add the instance id to the list we will // eventually terminate. instanceIds.add(describeResponse.getInstanceId()); } } catch (AmazonServiceException e) { // If we have an exception, ensure we don't break out // of the loop. This prevents the scenario where there // was blip on the wire.
AWS SDK for Java Developer Guide Getting Temporary AWS Credentials with SWS STS 245 } catch (AmazonServiceException e) { // Write out any exceptions that may have occurred. System.out.println("Error canceling instances"); System.out.println("Caught Exception: " + e.getMessage()); System.out.println("Reponse Status Code: " + e.getStatusCode()); System.out.println("Error Code: " + e.getErrorCode()); System.out.println("Request ID: " + e.
AWS SDK for Java Developer Guide (Optional) Activate and use an AWS STS region 2. Retrieve temporary security credentials from AWS STS. 3. Use the credentials to access AWS resources. Note Activating a region is optional; by default, temporary security credentials are obtained from the global endpoint sts.amazonaws.com.
AWS SDK for Java Developer Guide Use the temporary credentials to access AWS resources GetSessionTokenRequest session_token_request = new GetSessionTokenRequest(); session_token_request.setDurationSeconds(7200); // optional. The duration of temporary credentials can range from 900 seconds (15 minutes) to 129600 seconds (36 hours) for IAM users. If a duration isn't specified, then 43200 seconds (12 hours) is used by default.
AWS SDK for Java Developer Guide For more information For more information For more information about how to use temporary security credentials to access AWS resources, visit the following sections in the AWS Security Token Service User Guide: • Creating Temporary Security Credentials • Controlling Permissions for Temporary Security Credentials • Requesting AWS Resources Using Temporary Security Credentials • Activating AWS STS in a New Region Programming Amazon SWF with the AWS SDK for Java This section
AWS SDK for Java Developer Guide Listing Amazon SWF Domains } } Listing Amazon SWF Domains Using the AWS SDK for Java You can list the Amazon SWF domains associated with your account and AWS region by registration type. To list Amazon SWF domains 1. 2. 3. 4. Create a ListDomainsRequest object, and specify the registration status of the domains that you're interested in—this is required. Call AmazonSimpleWorkflowClient.listDomains with the ListDomainRequest object.
AWS SDK for Java Developer Guide Home Page for the AWS SDK for Java Additional Resources This section lists sources of additional information about using Amazon Web Services and the AWS SDK for Java. Topics • Home Page for the AWS SDK for Java (p. 66) • SDK Reference Documentation (p. 66) • AWS Java Developer Blog (p. 66) • AWS Forums (p. 67) • AWS Toolkit for Eclipse (p. 67) • SDK for Java Source Code and Samples (p. 67) • AWS SDK for Java Code Samples (p.
AWS SDK for Java Developer Guide AWS Forums AWS Forums Visit the AWS forums to ask questions or provide feedback about AWS. There is a forum specifically for AWS development in Java as well as forums for individual services such as Amazon S3. AWS engineers monitor the forums and respond to questions, feedback, and issues. You can subscribe to RSS feeds for any of the forums. To visit the AWS forums, visit aws.amazon.
AWS SDK for Java Developer Guide List of Code Samples Code Samples AmazonDynamoDB Demonstrates how to make basic requests to Amazon DynamoDB. AmazonDynamoDBDocumentAPI Contains a number of 'quickstart' samples for DynamoDB, including: • how to create a DynamoDB table with an LSI and GSI that can be accessed via a combination of hash keys and range keys. • how to add items to a table. • how to get items from a table. • how to query items on a table.
AWS SDK for Java Developer Guide Building and Running the Samples using the Command Line AwsFlowFramework These samples demonstrate how to use AWS Flow Framework. The following samples are included: • HelloWorld – this sample includes a simple workflow that calls an activity to print hello world to the console. It shows the basic usage of AWS Flow Framework, including defining contracts, implementation of activities and workflow coordination logic and worker programs to host them.
AWS SDK for Java Developer Guide Building and Running the Samples using the Eclipse IDE Before running any of the AWS SDK for Java samples, you will need to set your AWS credentials in the environment or with the AWS CLI as specified in Set Up your AWS Credentials for Use with the SDK for Java (p. 7).
AWS SDK for Java Developer Guide Building and Running the Samples using the Eclipse IDE 2. 3. 4. 5. 6. 7. 8. Create a new AWS Java project. In Eclipse, on the File menu, point to New, and then click Project. The New Project wizard opens. Expand the AWS category, then select AWS Java Project. Click Next. The project settings page is displayed. Enter a name in the Project Name box. The AWS SDK for Java Samples group displays the samples available in the SDK, as described previously.
AWS SDK for Java Developer Guide Document History The following table describes the important changes since the last release of the AWS SDK for Java Developer Guide. Last documentation update: May 14, 2014 Change Description Release Date Updated topics The introduction (p. 1) and getting started (p. 4) materMay 14, 2014 ial has been heavily revised to support the new guide structure and now includes guidance about how to Set Up your AWS Credentials for Use with the SDK for Java (p. 7).