Amazon AWS SDK Guia do Utilizador

Consulte online ou descarregue Guia do Utilizador para Software Amazon AWS SDK. Amazon AWS SDK User guide Manual do Utilizador

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir

Resumo do Conteúdo

Página 1 - AWS SDK for Java

AWS SDK for JavaDeveloper GuideVersion v1.0.0

Página 2

NoteYou can override the default location of the AWS credential file by setting theAWS_CREDENTIAL_FILE environment variable. For more information, see

Página 3 - Table of Contents

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

Página 4 - What is the AWS SDK for Java?

Using the Default Credential Provider ChainWhen you initialize a new service client without supplying any arguments, the SDK for Java will attemptto f

Página 5 - What's in this Guide?

Loading CredentialsOnce credentials have been set, you can load them using the SDK for Java default credential providerchain.To load credentials using

Página 6 - About Amazon Web Services

To explicitly supply credentials to an AWS client:Instantiate a class that provides the AWSCredentials interface, such as BasicAWSCredentials, supplyi

Página 7 - Getting Started

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

Página 8 - Install the AWS SDK for Java

Many resources available to help with configuring TCP buffer sizes and operating system specific TCPsettings, including:• TCP Tuning and Network Troub

Página 9

• To allow developers fine-grained control over the errors they want to handle without forcing them tohandle exceptional cases they aren't concer

Página 10 - Where to Go from Here

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

Página 11 - AWS SDK for Java Basics

log4j.rootLogger=WARN, A1log4j.appender.A1=org.apache.log4j.ConsoleAppenderlog4j.appender.A1.layout=org.apache.log4j.PatternLayoutlog4j.appender.A1.la

Página 12 - Setting Credentials

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

Página 13 - Loading Credentials

4 logger. Enabling the DEBUG level on the apache.http.wire logger enables logging for all requestand response data.The following log4j.properties file

Página 14 - AWS Region Selection

.withResources(new S3ObjectResource(myBucketName, "*"));Statement allowRestrictedWriteStatement = new Statement(Effect.Allow) .withPr

Página 15

.withActions(SNSActions.Subscribe) .withConditions(endpointCondition));AmazonSNS sns = new AmazonSNSClient(myAwsCredentials);sns.setTop

Página 16 - Exception Handling

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

Página 17

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

Página 18 - 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

Página 19 - Verbose Wire Logging

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

Página 20 - Access Control Policies

secretKey=YOUR_SECRET_KEYaccessKey=YOUR_ACCESS_KEYSpecify your AWS credentials as values for the secretKey and accessKey entries.To learn more aboutyo

Página 21

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

Página 22

IpPermission ipPermission = new IpPermission();ipPermission.withIpRanges("111.111.111.111/32", "150.150.150.150/32") .

Página 23 - DynamoDB

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

Página 24

To create a key pair and obtain the private key1. Create and initialize a CreateKeyPairRequest instance. Use the withKeyName method to set the keypair

Página 25

new RunInstancesRequest(); runInstancesRequest.withImageId("ami-4b814f22") .withInstanceType("m1.small")

Página 26 - Create an Amazon EC2 Client

Related ResourcesThe following table lists related resources that you'll find useful when using Amazon EC2 with the AWSSDK for Java.DescriptionRe

Página 27

Using IAM Roles with the SDK for JavaIf your application creates an AWS client using its default constructor (by providing the constructor withno argu

Página 28

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

Página 29 - Create a Key Pair

NotePolicies can also be represented in JSON format. Here is a policy that provides read ("Get" and"List") access to Amazon S3.{

Página 30 - Run an Amazon EC2 Instance

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

Página 31

{ System.out.println("Downloading an object"); S3Object s3object = s3Client.getObject( new GetObjectRequest(bucketNam

Página 32 - SDK for Java

Build and run the modified program. Since no credentials are stored in the program, unless you haveyour AWS credentials specified in your environment,

Página 33 - Object from an EC2 Instance

ssh -i key-pair-eclipse-1.pem [email protected] ant is not installed on the AMI that you selected, you can install i

Página 34

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

Página 35

• Determine when the Spot Request becomes fulfilled• Cancel the Spot Request• Terminate associated instancesPrerequisitesTo use this tutorial you need

Página 36 - Create your Application

• AWS Security Credentials in AWS General ReferenceNow that you have configured your settings, you can get started using the code in the example.Step

Página 37

// Get IP Address ipAddr = addr.getHostAddress()+"/10"; } catch (UnknownHostException e) { 35 } // Create a range that

Página 38 - Run the Program

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

Página 39 - Overview

LaunchSpecification for the request, which includes the instance type, AMI ID, and security groupyou want to use. Once the request is populated, you c

Página 40 - Prerequisites

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

Página 41

20 // Look through each request and determine if they are all in // the active state. for (SpotInstanceRequest describe

Página 42

To terminate any outstanding instances, you will need the instance ID associated with the request thatstarted them. The following code example takes o

Página 43

} } while (anyOpen);Using the instance IDs, stored in the ArrayList, terminate any running instances using the followingcode snippet. 1 tr

Página 44

Spot Instances can significantly lower your Amazon EC2 costs for batch processing, scientific research,image processing, video encoding, data and web

Página 45

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

Página 46

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

Página 47

// 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 {

Página 48 - Management

1 // Retrieves the credentials from an AWSCredentials.properties file. AWSCredentials credentials = null; try { 5 credentials = new P

Página 49

1 // Retrieves the credentials from an // AWSCredentials.properties file. AWSCredentials credentials = null; 5 try { credentials =

Página 50

1 // Retrieves the credentials from an AWSCredentials.properties file. AWSCredentials credentials = null; try { 5 credentials = new P

Página 51

Grouping Your Amazon EC2 Spot Instance RequestsYou have the option of grouping your Spot instance requests in several different ways. We'll look

Página 52

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,

Página 53

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

Página 54

with lower latency and high-bandwidth connectivity between the instances. An example of how to set aplacement group follows. 1 // Retrieves the c

Página 55

code examples are combined into one long code sample, which can be found in thecom.amazonaws.codesamples.advanced.InlineGettingStartedCodeSampleApp.ja

Página 56

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

Página 57

// Create the block device mapping to describe the root partition.BlockDeviceMapping blockDeviceMapping = new BlockDeviceMapping();blockDeviceMapping.

Página 58

* or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR

Página 59 - Termination

//================ Submitting a Request ========================// //==============================================================//

Página 60

// Add all of the request ids to the hashset, so we can120 // determine when they hit the active state. for (SpotInstanceRequest re

Página 61

DescribeSpotInstanceRequestsResult describeResult = ec2.describeS potInstanceRequests(describeRequest);175 List<SpotInstanceReq

Página 62

230 System.out.println("Request ID: " + e.getRequestId());} //===========================================================//

Página 63

Programming Amazon SWF with the AWS SDKfor JavaThis section provides information specific to programming Amazon SWF with the SDK for Java.Topics• Regi

Página 64

To list Amazon SWF domains1. Create a ListDomainsRequest object, and specify the registration status of the domains that you'reinterested in—this

Página 65 - Bringing It All Together

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

Página 66

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

Página 67 - To list Amazon SWF domains

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,

Página 68 - Additional Resources

• AmazonEC2SpotInstances-Advanced – demonstrates persistent vs. one-time spot requests, launchgroups, and availability groups.• AmazonEC2SpotInstances

Página 69 - AWS SDK for Java Code Samples

ant<step></step>The sample prints information to standard output. for example: =========================================== Welcome to

Página 70 - Command Line

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

Página 71 - Eclipse IDE

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

Página 72 - To run the project

NoteTo create access keys, you must have permissions to perform the required IAM actions. Formore information, see Granting IAM User Permission to Man

Página 73 - Document History

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

Comentários a estes Manuais

Sem comentários