AWS SDK for JavaDeveloper GuideVersion v1.0.0
NoteYou can override the default location of the AWS credential file by setting theAWS_CREDENTIAL_FILE environment variable. For more information, see
AWS SDK for Java BasicsThis section provides important general information about programming with the AWS SDK for Java.Information in this section app
Using the Default Credential Provider ChainWhen you initialize a new service client without supplying any arguments, the SDK for Java will attemptto f
Loading CredentialsOnce credentials have been set, you can load them using the SDK for Java default credential providerchain.To load credentials using
To explicitly supply credentials to an AWS client:Instantiate a class that provides the AWSCredentials interface, such as BasicAWSCredentials, supplyi
The AWS SDK for Java uses the US East (Northern Virginia) Region as the default region if you do notspecify a region in your code. However, the AWS Ma
Many resources available to help with configuring TCP buffer sizes and operating system specific TCPsettings, including:• TCP Tuning and Network Troub
• To allow developers fine-grained control over the errors they want to handle without forcing them tohandle exceptional cases they aren't concer
Logging AWS SDK for Java CallsThe AWS SDK for Java is instrumented with Apache Commons Logging, which is an abstraction layerthat enables the use of a
log4j.rootLogger=WARN, A1log4j.appender.A1=org.apache.log4j.ConsoleAppenderlog4j.appender.A1.layout=org.apache.log4j.PatternLayoutlog4j.appender.A1.la
AWS SDK for Java: Developer GuideCopyright © 2014 Amazon Web Services, Inc. and/or its affiliates. All rights reserved.The following are trademarks of
4 logger. Enabling the DEBUG level on the apache.http.wire logger enables logging for all requestand response data.The following log4j.properties file
.withResources(new S3ObjectResource(myBucketName, "*"));Statement allowRestrictedWriteStatement = new Statement(Effect.Allow) .withPr
.withActions(SNSActions.Subscribe) .withConditions(endpointCondition));AmazonSNS sns = new AmazonSNSClient(myAwsCredentials);sns.setTop
Using Amazon Web Services withthe AWS SDK for JavaThis section provides information about how to program various Amazon Web Services using the SDKfor
Downloading the Session ManagerYou can download the session manager from the aws/aws-dynamodb-session-tomcat project on GitHub.That project also hosts
• A config file that copies the jar into Tomcat's lib directory and applies the overridden context.xmlfile.You can find in more information on cu
TroubleshootingIf you encounter issues with the session manager, the first place to look is in catalina.out. If you haveaccess to the Tomcat installat
secretKey=YOUR_SECRET_KEYaccessKey=YOUR_ACCESS_KEYSpecify your AWS credentials as values for the secretKey and accessKey entries.To learn more aboutyo
If you want to allow inbound traffic, create a security group and assign a rule to it that allows the ingressthat you want.Then associate the new secu
IpPermission ipPermission = new IpPermission();ipPermission.withIpRanges("111.111.111.111/32", "150.150.150.150/32") .
Table of ContentsWhat is the AWS SDK for Java? ...
To create a key pair and obtain the private key1. Create and initialize a CreateKeyPairRequest instance. Use the withKeyName method to set the keypair
new RunInstancesRequest(); runInstancesRequest.withImageId("ami-4b814f22") .withInstanceType("m1.small")
Related ResourcesThe following table lists related resources that you'll find useful when using Amazon EC2 with the AWSSDK for Java.DescriptionRe
Using IAM Roles with the SDK for JavaIf your application creates an AWS client using its default constructor (by providing the constructor withno argu
To create the IAM role to give S3 read-only access to your EC2 instance1. Log in to the AWS Management Console and go to IAM.2. Select Roles in the le
NotePolicies can also be represented in JSON format. Here is a policy that provides read ("Get" and"List") access to Amazon S3.{
Create your ApplicationWe'll now build the application that will run on the Amazon EC2 instance. First, create a directory thatyou can use to hol
{ System.out.println("Downloading an object"); S3Object s3object = s3Client.getObject( new GetObjectRequest(bucketNam
Build and run the modified program. Since no credentials are stored in the program, unless you haveyour AWS credentials specified in your environment,
ssh -i key-pair-eclipse-1.pem [email protected] ant is not installed on the AMI that you selected, you can install i
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 applicatio
• Determine when the Spot Request becomes fulfilled• Cancel the Spot Request• Terminate associated instancesPrerequisitesTo use this tutorial you need
• AWS Security Credentials in AWS General ReferenceNow that you have configured your settings, you can get started using the code in the example.Step
// Get IP Address ipAddr = addr.getHostAddress()+"/10"; } catch (UnknownHostException e) { 35 } // Create a range that
2. In the window that displays AMIs, just use the AMI ID as shown in the following screen shot.Alternatively, you can use the DescribeImages API, but
LaunchSpecification for the request, which includes the instance type, AMI ID, and security groupyou want to use. Once the request is populated, you c
Step 4: Determining the State of Your Spot RequestNext, we want to create code to wait until the Spot request reaches the "active" state bef
20 // Look through each request and determine if they are all in // the active state. for (SpotInstanceRequest describe
To terminate any outstanding instances, you will need the instance ID associated with the request thatstarted them. The following code example takes o
} } while (anyOpen);Using the instance IDs, stored in the ArrayList, terminate any running instances using the followingcode snippet. 1 tr
Spot Instances can significantly lower your Amazon EC2 costs for batch processing, scientific research,image processing, video encoding, data and web
Developing AWS Applications for AndroidIf you are an Android developer, Amazon Web Services publishes a separate SDK specifically for Androiddevelopme
Related topics• What Is IAM? in Using IAM• AWS Security Credentials in AWS General ReferenceStep 2: Setting Up a Security GroupA security group acts a
// Get the IP of the current host, so that we can limit the Security Group // by default to the ip range associated with your subnet. 30 try {
1 // Retrieves the credentials from an AWSCredentials.properties file. AWSCredentials credentials = null; try { 5 credentials = new P
1 // Retrieves the credentials from an // AWSCredentials.properties file. AWSCredentials credentials = null; 5 try { credentials =
1 // Retrieves the credentials from an AWSCredentials.properties file. AWSCredentials credentials = null; try { 5 credentials = new P
Grouping Your Amazon EC2 Spot Instance RequestsYou have the option of grouping your Spot instance requests in several different ways. We'll look
questRequest);If you want to ensure that all instances within a request are launched in the same Availability Zone, andyou don't care which one,
You can specify an Availability Zone that you want for your Spot Instances. The following code exampleshows you how to set an Availability Zone. 1
with lower latency and high-bandwidth connectivity between the instances. An example of how to set aplacement group follows. 1 // Retrieves the c
code examples are combined into one long code sample, which can be found in thecom.amazonaws.codesamples.advanced.InlineGettingStartedCodeSampleApp.ja
About Amazon Web ServicesAmazon Web Services (AWS) is a collection of digital infrastructure services that developers can leveragewhen developing thei
// Create the block device mapping to describe the root partition.BlockDeviceMapping blockDeviceMapping = new BlockDeviceMapping();blockDeviceMapping.
* or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR
//================ Submitting a Request ========================// //==============================================================//
// Add all of the request ids to the hashset, so we can120 // determine when they hit the active state. for (SpotInstanceRequest re
DescribeSpotInstanceRequestsResult describeResult = ec2.describeS potInstanceRequests(describeRequest);175 List<SpotInstanceReq
230 System.out.println("Request ID: " + e.getRequestId());} //===========================================================//
Programming Amazon SWF with the AWS SDKfor JavaThis section provides information specific to programming Amazon SWF with the SDK for Java.Topics• Regi
To list Amazon SWF domains1. Create a ListDomainsRequest object, and specify the registration status of the domains that you'reinterested in—this
Additional ResourcesThis section lists sources of additional information about using Amazon Web Services and the AWS SDKfor Java.Topics• Home Page for
AWS ForumsVisit the AWS forums to ask questions or provide feedback about AWS.There is a forum specifically forAWS development in Java as well as foru
Getting StartedThis section provides information about how to install, set up and use the SDK for Java. If you have neverused the SDK for Java before,
• AmazonEC2SpotInstances-Advanced – demonstrates persistent vs. one-time spot requests, launchgroups, and availability groups.• AmazonEC2SpotInstances
ant<step></step>The sample prints information to standard output. for example: =========================================== Welcome to
To run the project1. Select the sample .java file you want to run. For example, for the Amazon S3 sample, selectS3Sample.java.2. Select Run from the R
Document HistoryThe following table describes the important changes since the last release of the AWS SDK for JavaDeveloper Guide.Last documentation u
NoteTo create access keys, you must have permissions to perform the required IAM actions. Formore information, see Granting IAM User Permission to Man
If you intend to use the SDK for Java with the Eclipse IDE, you should install the AWS Toolkit for Eclipse,which automatically includes the AWS SDK fo
Komentáře k této Příručce