Amazon AWS SDK Betriebsanweisung

Stöbern Sie online oder laden Sie Betriebsanweisung nach Software Amazon AWS SDK herunter. Amazon AWS SDK User guide Benutzerhandbuch

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken

Inhaltsverzeichnis

Seite 1 - AWS SDK for Java

AWS SDK for JavaDeveloper GuideVersion v1.0.0

Seite 2

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

Seite 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

Seite 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

Seite 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

Seite 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

Seite 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

Seite 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

Seite 9

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

Seite 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

Seite 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

Seite 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

Seite 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

Seite 14 - AWS Region Selection

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

Seite 15

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

Seite 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

Seite 17

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

Seite 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

Seite 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

Seite 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

Seite 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

Seite 22

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

Seite 23 - DynamoDB

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

Seite 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

Seite 25

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

Seite 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

Seite 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

Seite 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

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

Seite 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

Seite 31

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

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

Seite 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

Seite 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

Seite 35

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

Seite 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

Seite 37

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

Seite 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

Seite 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

Seite 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

Seite 41

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

Seite 42

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

Seite 43

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

Seite 44

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

Seite 45

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

Seite 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

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

Seite 48 - Management

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

Seite 49

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

Seite 50

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

Seite 51

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

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

Seite 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

Seite 54

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

Seite 55

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

Seite 56

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

Seite 57

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

Seite 58

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

Seite 59 - Termination

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

Seite 60

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

Seite 61

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

Seite 62

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

Seite 63

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

Seite 64

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

Seite 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

Seite 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

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

Seite 68 - Additional Resources

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

Seite 69 - AWS SDK for Java Code Samples

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

Seite 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

Seite 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

Seite 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

Seite 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

Kommentare zu diesen Handbüchern

Keine Kommentare