Amazon AWS SDK Podręcznik Użytkownika

Przeglądaj online lub pobierz Podręcznik Użytkownika dla Oprogramowanie Amazon AWS SDK. Amazon AWS SDK User guide Instrukcja obsługi

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj

Podsumowanie treści

Strona 1 - AWS SDK for Java

AWS SDK for JavaDeveloper GuideVersion v1.0.0

Strona 2

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

Strona 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

Strona 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

Strona 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

Strona 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

Strona 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

Strona 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

Strona 9

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

Strona 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

Strona 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

Strona 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

Strona 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

Strona 14 - AWS Region Selection

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

Strona 15

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

Strona 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

Strona 17

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

Strona 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

Strona 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

Strona 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

Strona 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

Strona 22

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

Strona 23 - DynamoDB

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

Strona 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

Strona 25

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

Strona 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

Strona 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

Strona 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

Strona 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.{

Strona 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

Strona 31

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

Strona 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,

Strona 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

Strona 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

Strona 35

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

Strona 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

Strona 37

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

Strona 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

Strona 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

Strona 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

Strona 41

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

Strona 42

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

Strona 43

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

Strona 44

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

Strona 45

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

Strona 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

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

Strona 48 - Management

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

Strona 49

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

Strona 50

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

Strona 51

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

Strona 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,

Strona 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

Strona 54

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

Strona 55

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

Strona 56

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

Strona 57

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

Strona 58

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

Strona 59 - Termination

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

Strona 60

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

Strona 61

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

Strona 62

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

Strona 63

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

Strona 64

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

Strona 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

Strona 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

Strona 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,

Strona 68 - Additional Resources

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

Strona 69 - AWS SDK for Java Code Samples

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

Strona 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

Strona 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

Strona 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

Strona 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

Komentarze do niniejszej Instrukcji

Brak uwag