Amazon AWS SDK Guide de l'utilisateur

Naviguer en ligne ou télécharger Guide de l'utilisateur pour Logiciel Amazon AWS SDK. Amazon AWS SDK User guide Manuel d'utilisatio

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 76
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 0
AWS SDK for Java
Developer Guide
Version v1.0.0
Vue de la page 0
1 2 3 4 5 6 ... 75 76

Résumé du contenu

Page 1 - AWS SDK for Java

AWS SDK for JavaDeveloper GuideVersion v1.0.0

Page 2

To download and install the SDK for Java1. Download the SDK for Java from the SDK web page at http://aws.amazon.com/sdkforjava.2. After downloading th

Page 3 - Table of Contents

Set Up your AWS Credentials for Use with theSDK for JavaTo connect to any of the supported services with the SDK for Java, you must provide your AWS c

Page 4

Explore the SDK for Java Code SamplesThe SDK for Java is packaged with a number of code samples, which you can browse on your machineor view on GitHub

Page 5 - What is the AWS SDK for Java?

AWS SDK for Java BasicsThis section provides important general information about programming with the AWS SDK for Java.Information in this section app

Page 6 - What's in this Guide?

Topics• Using the Default Credential Provider Chain (p. 10)• Specifying a Credential Provider or Provider Chain (p.12)• Explicitly Specifying Credenti

Page 7 - About Amazon Web Services

To override the default credentials file location• Set the AWS_CREDENTIAL_FILE environment variable to the location of your AWS credentials file.On Li

Page 8 - Getting Started

Specifying a Credential Provider or Provider ChainIf you want to specify a different credential provider than the default credential provider chain, y

Page 9 - Install the AWS SDK for Java

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 R

Page 10 - Building the SDK with Maven

AmazonEC2 ec2 = new AmazonEC2(myCredentials);ec2.setRegion(Region.getRegion(Regions.US_WEST_2));ImportantAmazonWebServiceClient.setRegion is not threa

Page 11 - SDK for Java

If you're connecting to the Internet through a proxy server, you'll need to configure your proxy serversettings (proxy host, port and userna

Page 12 - Where to Go from Here

AWS SDK for Java: Developer GuideCopyright © 2015 Amazon Web Services, Inc. and/or its affiliates. All rights reserved.The following are trademarks of

Page 13 - AWS SDK for Java Basics

TCP Socket Buffer Size HintsAdvanced users who want to tune low-level TCP parameters can additionally set TCP buffer size hintsthrough the ClientConfi

Page 14 - Setting Credentials

java.security.Security.setProperty("networkaddress.cache.ttl" , "60");Note that the JVM is a shared resource; multiple Java applic

Page 15 - Loading Credentials

AmazonClientExceptionThis exception indicates that a problem occurred inside the Java client code, either while trying to senda request to AWS or whil

Page 16

<fileset dir="../../third-party" includes="**/*.jar"/> <fileset dir="../../lib" includes="**/*.jar"

Page 17 - AWS Region Selection

POST https://rds.amazonaws.com / Parameters: (MaxRecords: 20, Action: Descri beEngineDefaultParameters, SignatureMethod: HmacSHA256, AWSAccessKeyId: A

Page 18 - Proxy Configuration

A is the principalThe AWS account that is making a request to access or modify one of your AWS resources.B is the actionThe way in which your AWS reso

Page 19 - HTTP Transport Configuration

AmazonSQS sqs = new AmazonSQSClient(myAwsCredentials);sqs.setQueueAttributes(new SetQueueAttributesRequest(myQueueUrl, queueAttrib utes));Amazon SNS E

Page 20 - TCP Socket Buffer Size Hints

Using Amazon Web Services withthe AWS SDK for JavaThis section provides information about how to program various Amazon Web Services using the SDKfor

Page 21 - Exception Handling

Downloading the Session ManagerYou can download the session manager from the aws/aws-dynamodb-session-tomcat project on GitHub.That project also hosts

Page 22 - Setting the Classpath

• 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

Page 23

Table of ContentsWhat is the AWS SDK for Java? ...

Page 24 - Access Control Policies

TroubleshootingIf you encounter issues with the session manager, the first place to look is in catalina.out. If you haveaccess to the Tomcat installat

Page 25

AWSCredentials credentials = new PropertiesCredentials( AwsConsoleApp.class.getResourceAsStream("AwsCredentials.proper ties"));2. Us

Page 26 - Amazon SNS Example

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 s

Page 27 - DynamoDB

Create a Key PairYou must specify a key pair when you launch an EC2 instance and then specify the private key of thekey pair when you connect to the i

Page 28

.withMaxCount(1) .withKeyName("my-key-pair") .withSecurityGroups("my-secur

Page 29

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.

Page 30 - Limitations

5. On the Set Permissions page, under Select Policy Template, select Amazon S3 Read OnlyAccess. Click Next Step.6. On the Review page, click Create Ro

Page 31 - To create a security group

} catch(AmazonClientException ace) { System.out.println( "AmazonClientException" ); } } private static void displayTextI

Page 32

run: [java] Downloading an object [java] AmazonServiceExceptionBUILD SUCCESSFULTransfer the Compiled Program to Your EC2 InstanceTransfer the prog

Page 33 - Run an Amazon EC2 Instance

Tutorial: Amazon EC2 Spot InstancesOverviewSpot Instances allow you to bid on unused Amazon Elastic Compute Cloud (Amazon EC2) capacity andrun the acq

Page 34 - Resources on Amazon EC2

Listing Amazon SWF Domains ... 65Additional Resources ...

Page 35 - Create an IAM Role

Step 1: Setting Up Your CredentialsTo begin using this code sample, you need to populate your credentials in theAwsCredentials.properties file. Specif

Page 36 - Create your Application

After we create an AmazonEC2 client object, we create a CreateSecurityGroupRequest object withthe name, "GettingStarted" and a description f

Page 37 - For example:

ipPermission.setFromPort(new Integer(22)); ipPermission.setToPort(new Integer(22)); ipPermission.setIpRanges(ipRanges); ipPermissions.add

Page 38

There are many ways to approach bidding for Spot instances; to get a broad overview of the variousapproaches you should view the Bidding for Spot Inst

Page 39 - Prerequisites

RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); // Request 1 x t1.micro instance with a bid price of $0.03.

Page 40

10 // active state. for (SpotInstanceRequest requestResponse : requestResponses) { System.out.println("Created Spot Request: "+re

Page 41

} catch (Exception e) { // Do nothing because it woke up early. } 45 } while (anyOpen); After running this code, your Spot I

Page 42

try { // Retrieve all of the requests we want to monitor. 20 DescribeSpotInstanceRequestsResult describeResult = ec2.descri

Page 43

Bringing It All TogetherTo bring this all together, we provide a more object-oriented approach that combines the preceding stepswe showed: initializin

Page 44

Step 1: Setting Up Your CredentialsTo begin using this code sample, you need to populate your credentials in theAwsCredentials.properties file. Specif

Page 45

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

Page 46

After we create an AmazonEC2 client object, we create a CreateSecurityGroupRequest object withthe name, "GettingStarted" and a description f

Page 47

ArrayList<IpPermission> ipPermissions = new ArrayList<IpPermission> (); 45 IpPermission ipPermission = new IpPermission(); ipPermis

Page 48 - Management

// Initializes a Spot Instance Request RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); // Request 1 x t1.mi

Page 49

// Initializes a Spot Instance Request RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); 20 // Request 1 x t1.mi

Page 50

// Initializes a Spot Instance Request RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); // Request 1 x t1.mi

Page 51

GettingStartedApp.class.getResourceAsStream("AwsCredentials.proper ties")); } catch (IOException e1) { System.out.prin

Page 52

} catch (IOException e1) { System.out.println("Credentials were not properly entered into AwsCre dentials.properties."); S

Page 53

} // Create the AmazonEC2Client object so we can call various APIs. AmazonEC2 ec2 = new AmazonEC2Client(credentials); 15 // Initializes

Page 54

10 System.exit(-1); } // Create the AmazonEC2Client object so we can call various APIs. AmazonEC2 ec2 = new AmazonEC2Client(credentials)

Page 55

interruption or termination.We've inserted new code in the following example that shows how to enablethis scenario.In the added code, we create a

Page 56

Developing AWS Applications for AndroidIf you are an Android developer, Amazon Web Services publishes a separate SDK specifically for Androiddevelopme

Page 57

blockList.add(blockDeviceMapping);// Set the block device mapping configuration in the launch specifications. 50 launchSpecification.setBlockDeviceMap

Page 58 - Termination

import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.PropertiesCredentials; 25 import com.amazonaws.codesamples.getting_started.

Page 59

System.out.println(e1.getMessage()); System.exit(-1); } 80 // Create the AmazonEC2Client object so we can // call

Page 60

130 // Create the list of tags we want to createArrayList<Tag> requestTags = new ArrayList<Tag>();requestTags.add(new Tag("keynam

Page 61

if (describeResponse.getState().equals("open")) {185 anyOpen = true; break; }

Page 62

} catch (AmazonServiceException e) { // Write out any exceptions that may have occurred. System.out.println("Error canc

Page 63

2. Retrieve temporary security credentials from AWS STS.3. Use the credentials to access AWS resources.NoteActivating a region is optional; by default

Page 64

GetSessionTokenRequest session_token_request = new GetSessionTokenRequest();session_token_request.setDurationSeconds(7200); // optional.The duration o

Page 65 - Bringing It All Together

For more informationFor more information about how to use temporary security credentials to access AWS resources, visitthe following sections in the A

Page 66 - Important

}}Listing Amazon SWF Domains Using the AWS SDKfor JavaYou can list the Amazon SWF domains associated with your account and AWS region by registrat

Page 67

About Amazon Web ServicesAmazon Web Services (AWS) is a collection of digital infrastructure services that developers can leveragewhen developing thei

Page 68 - For more information

Additional ResourcesThis section lists sources of additional information about using Amazon Web Services and the AWS SDKfor Java.Topics• Home Page for

Page 69 - To list Amazon SWF domains

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

Page 70 - Additional Resources

Code SamplesDemonstrates how to make basic requests toAmazon DynamoDB.AmazonDynamoDBContains a number of 'quickstart' samples for Dy-namoDB,

Page 71 - AWS SDK for Java Code Samples

These samples demonstrate how to use AWS FlowFramework.The following samples are included:• HelloWorld – this sample includes a simpleworkflow that ca

Page 72 - Code Samples

Before running any of the AWS SDK for Java samples, you will need to set your AWS credentials in theenvironment or with the AWS CLI as specified in Se

Page 73 - Command Line

2. Create a new AWS Java project. In Eclipse, on the File menu, point to New, and then click Project.The New Project wizard opens.3. Expand the AWS ca

Page 74 - Eclipse IDE

Document HistoryThe following table describes the important changes since the last release of the AWS SDK for JavaDeveloper Guide.Last documentation u

Page 75 - To run the project

Getting StartedThis section provides information about how to install, set up, and use the SDK for Java. If you havenever used the SDK for Java before

Page 76 - Document History

To provide access credentials for an IAM user1. Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.

Commentaires sur ces manuels

Pas de commentaire